#include #include #include #include #include //#include using namespace std; using namespace atcoder; #define ull unsigned long long #define ll long long #define Pll pair #define INF 1000000000000000000 ull min(ull x,ull y){ if(x>y)return y; return x; } ll gcd(ll x,ll y){ if(x%y)return y; return gcd(y,x%y); } ll lcm(ll x,ll y){ return x/gcd(x,y)*y; } signed main(){ ll N,M,K; ull ans=INF; cin>>N>>M; vector A(N); vector B(M); vectorr(2); vectorm={N,M}; K=lcm(N,M); for(ull i=0;i>A.at(i); for(ull i=0;i>B.at(i); for(ull i=0;i