#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int a,b; cin >> a >> b; int tile = a*a+b*b,n = tile; int sx = 0,sy = 0,x = 0,y = 0; while(tile--){ cout << x << " " << y << "\n"; x = (x+a)%n, y = (y+b)%n; if(x == sx && y == sy){ sx = (sx+a-b+n)%n; sy = (sy+a+b)%n; x = sx; y = sy; } } tile = n; sx = a,sy = 0,x = a,y = 0; while(tile--){ cout << x << " " << y << "\n"; x = (x+a)%n, y = (y+b)%n; if(x == sx && y == sy){ sx = (sx+a-b+n)%n; sy = (sy+a+b)%n; x = sx; y = sy; } } }