#include <stdio.h>
int main() {
int n, a, b;
scanf("%d %d %d", &n, &a, &b);
char x[300];
char y[300];
for (int i = 0; i < a; i++) {
scanf(" %c", &x[i]);
}
for (int j = 0; j < b; j++) {
scanf(" %c", &y[j]);
}
int score1=0,score2=0;
for (int i = 0; i < n; i++) {
int flag;
int t=i%a;
int m=i%b;
if (x[t] == '0' && (y[m] == '2' || y[m] == '3')) flag = 1;
else if (x[t] == '1' && (y[m] == '0' || y[m] == '3')) flag = 1;
else if (x[t] == '2' && (y[m] == '1' || y[m] == '4'))flag = 1;
else if (x[t] == '3' && (y[m] == '2' || y[m] == '4')) flag = 1;
else if (x[t] == '4' && (y[m] == '0' || y[m] == '1')) flag = 1;
else if (x[t] == y[t])flag = 0;
else flag = 2;
if (1 == flag) score1++;
else if(2==flag)score2++;
}
printf("%d %d", score1, score2);
return 0;
}