#include using namespace std; #define ll long long #define pll pair #define ff first #define ss second #define pb push_back const int mod = 1e9 + 7; int main() { ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n, m; cin >> n >> m; vector a(n), b(m); for(int i=0; i> a[i]; for(int j=0; j> b[j]; int prod = (n * m) / (__gcd(n, m)); for(int i=0; i