ll p[40]; map<ll, int> ma; intmain(){ ios::sync_with_stdio(0); ll a, b, c; int k; p[0] = 1; for (int i = 1; i<= 32; i++) p[i] = 2 * p[i - 1]; while(cin >> a >> b >> c >> k){ if (!a && !b && !c && !k) break; ma.clear(); if (b < a) b += p[k]; int flag = 0; while((b - a) % c != 0){ if (ma[(b - a) % c]){ flag = 1; break; } ma[(b - a) % c] = 1; b += p[k]; } if (flag) cout << "FOREVER\n"; else cout << (b - a) / c << "\n"; } return0; }