#include using namespace std; #ifdef ONLINE_JUDGE #define dbg(...) #else #include "debug.h" #endif #define ll long long #define endl '\n' #define all(x) x.begin(), x.end() #define sz(x) (int)(x).size() #define yes cout<<"YES"<>=1;}return ans;} void solve() { int n,m,k; string s1,s2; cin>>n>>s1>>s2; m=s1.size(), k=s2.size(); int l = lcm(m,k); string str1 = s1; string str2 = s2; for(int i=0; i<=l/m; i++) str1+=s1; for(int i=0; i<=l/k; i++) str2+=s2; int p=n/l; int q=n%l; ll ct1=0,ct2=0,ans1=0,ans2=0; for(int i=0; i> TC; while (TC--) solve(); }