#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 = a*a+b*b; int x = 0,y = 0; while(tile--){ cout << x << " " << y << "\n"; x = (x+a)%n,y = (y+b)%n; } x = a,y = 0; tile = n; while(tile--){ cout << x << " " << y << "\n"; x = (x+a)%n; y = (y+b)%n; } }