#include #define rep(i, n) for (int i = 0; i < n; ++i) using ll = long long; using namespace std; const int INF = 1e9; int main() { ll A, B, now = 0; cin >> A >> B; if (B == 0) cout << 1; else if (A >= 1) cout << -1; else if (A == -1) cout << 2; else { int ans = 0; do { now = A * now + B; cout << now << endl; ++ans; if (ans == 100000) { ans = -1; break; } } while (now != 0); cout << ans; } cout << endl; return 0; }