#include using namespace std; int main(){ int A, B; cin >> A >> B; vector> X, Y; bool rev = 0; if (A > B) swap(A, B), rev = 1; int P = 0, Q = 0; int L = A * A + B * B; set> s; while (!s.count({P, Q})){ while (!s.count({P, Q})){ s.insert({P, Q}); X.push_back({P, Q}); Y.push_back({(P + A) % L, Q}); P = (P + L - B) % L; Q = (Q + A) % L; } P = (P + A) % L; Q = (Q + B) % L; } if (rev) swap(X, Y); for (auto x : X) cout << x.first << " " << x.second << "\n"; for (auto y : Y) cout << y.first << " " << y.second << "\n"; }