#include<iostream>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int na,nb,ma,mb,k=0,pi,pj,x,y,sum,tt,uu,max;char c;
    char *s=new char[100];int a[100][100],b[100][100];
    cin>>na>>nb;
    for(int i=0;i<na;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            a[i+1][k++]=s[j]-'0';//cout<<a[j+1][k-1]<<" ";
        }
    }

    cin>>ma>>mb;
    for(int i=0;i<ma;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            b[i+1][k++]=(s[j]-'0');//cout<<b[j+1][k-1]<<" ";
        }
    }
    /*for(int i=1;i<=na;i++)
    {
        for(int j=1;j<=nb;j++)
        cout<<a[i][j]<<" ";
        cout<<endl;
    }*/
    max=-5;
    for(int i=-50;i<=50;i++)
    {
        for(int j=-50;j<=50;j++)
        {
            x=i;y=j;sum=0;
            for(int t=1;t<=na;t++)
            {
                for(int u=1;u<=nb;u++)
                {
                    tt=t+x;uu=u+y;
                    if((tt>=1&&tt<=ma)&&(uu>=1&&uu<=mb))
                    {
                        sum+=(a[t][u]*b[tt][uu]);
                    }
                }
            }
            if(sum>max)
            {
                max=sum;
                pi=x;pj=y;
            }
        }
    }
    cout<<pi<<" "<<pj;
}


#include<iostream>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
    int na,nb,ma,mb,k=0,pi,pj,x,y,sum,tt,uu,max;char c;
    char *s=new char[100];int a[100][100],b[100][100];
    cin>>na>>nb;
    for(int i=0;i<na;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            a[i+1][k++]=s[j]-'0';//cout<<a[j+1][k-1]<<" ";
        }
    }

    cin>>ma>>mb;
    for(int i=0;i<ma;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            b[i+1][k++]=(s[j]-'0');//cout<<b[j+1][k-1]<<" ";
        }
    }
    /*for(int i=1;i<=na;i++)
    {
        for(int j=1;j<=nb;j++)
        cout<<a[i][j]<<" ";
        cout<<endl;
    }*/
    max=-5;
    for(int i=-ma;i<=ma;i++)
    {
        for(int j=-mb;j<=mb;j++)
        {
            x=i;y=j;sum=0;//cout<<x<<" "<<y<<endl;
            for(int t=1;t<=na;t++)
            {
                for(int u=1;u<=nb;u++)
                {
                    tt=t+x;uu=u+y;
                    /*if(x==0&&y==1)
                    {
                        cout<<tt<<" "<<uu<<"\t";
                    }*/
                    if((tt>=1&&tt<=ma)&&(uu>=1&&uu<=mb))
                    {
                        sum+=(a[t][u]*b[tt][uu]);
                    }
                }
            }
            if(sum>max){max=sum;//cout<<sum<<" sum"<<endl;
            pi=x;pj=y;}
        }
    }
    //cout<<pi<<" "<<pj;
}


#include<iostream>
#include<utility>
#include<algorithm>
#include<cstdio>
using namespace std;
int main()
{
    int na,nb,ma,mb,k=0,pi,pj,x,y,sum,tt,uu,max;char c;
    char *s=new char[100];int a[100][100],b[100][100];
    cin>>na>>nb;
    for(int i=0;i<na;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            a[i+1][k++]=s[j]-'0';//cout<<a[j+1][k-1]<<" ";
        }
    }

    cin>>ma>>mb;
    for(int i=0;i<ma;i++)
    {
        scanf("%s",s);k=1;
        for(int j=0;j<strlen(s);j++)
        {
            b[i+1][k++]=(s[j]-'0');//cout<<b[j+1][k-1]<<" ";
        }
    }
    /*for(int i=1;i<=na;i++)
    {
        for(int j=1;j<=nb;j++)
        cout<<a[i][j]<<" ";
        cout<<endl;
    }*/
    max=-5;
    for(int i=-ma;i<=ma;i++)
    {
        for(int j=-mb;j<=mb;j++)
        {
            x=i;y=j;sum=0;//cout<<x<<" "<<y<<endl;
            for(int t=1;t<=na;t++)
            {
                for(int u=1;u<=nb;u++)
                {
                    tt=t+x;uu=u+y;
                    /*if(x==0&&y==1)
                    {
                        cout<<tt<<" "<<uu<<"\t";
                    }*/
                    if((tt>=1&&tt<=ma)&&(uu>=1&&uu<=mb))
                    {
                        sum+=(a[t][u]*b[tt][uu]);
                    }
                }
            }
            if(sum>max){max=sum;//cout<<sum<<" sum"<<endl;
            pi=x;pj=y;}
        }
    }
    cout<<pi<<" "<<pj;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   long na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-100,pas1=0,pas2=0,s;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
           for (x=-50;x<=50;x++)
               for (y=-50;y<50;y++){
                   s=0;
                    for (i=1;i<=na;i++)
                        for (j=1;j<=ma;j++)
                            if (i+x<=nb && j+y<=mb && i+x>=1 && j+y>=1)
                            if ( a[i][j]==1 && b[i+x][j+y]==1 ) s=s+1;
                   if (s>max) {max=s; pas1=x; pas2=y;};
               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   long na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-100,pas1=0,pas2=0;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
    for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++)
           for (x=-i+1;x<=nb-i;x++)
               for (y=-j+1;y<=mb-j;y++){
                   if (a[i][j]*b[i+x][j+y]>max){
                      max=a[i][j]*b[i+x][j+y];
                      pas1=x; pas2=y;
                   };

               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   int na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-100,pas1,pas2;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
    for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++)
           for (x=-i+1;x<=nb-i;x++)
               for (y=-j+1;y<=mb-j;y++){

                   if (a[i][j]*b[i+x][j+y]>max){
                      max=a[i][j]*b[i+x][j+y];
                      pas1=x; pas2=y;
                   };

               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   int na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-100,pas1=0,pas2=0;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
    for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++)
           for (x=-i+1;x<=nb-i;x++)
               for (y=-j+1;y<=mb-j;y++){
                   if (a[i][j]*b[i+x][j+y]>max){
                      max=a[i][j]*b[i+x][j+y];
                      pas1=x; pas2=y;
                   };

               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   int na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-1,pas1,pas2;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
    for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++)
           for (x=-i+1;x<=nb;x++)
               for (y=-j+1;y<=mb;y++){

                   if (a[i][j]*b[i+x][j+y]>max){
                      max=a[i][j]*b[i+x][j+y];
                      pas1=x; pas2=y;
                   };

               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


#include<iostream>
#include<stdio.h>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<fstream>
#include<string>
#include<stack>
#include <iomanip>
#define PI 3.141592653589793

using namespace std;
int main(){
 //freopen("input.txt","r",stdin);
 //freopen("output.txt","w",stdout);
   int na,ma,nb,mb,x,y,a[100][100],b[100][100],i,j,max=-1,pas1,pas2;
   char ch;
   cin>>na>>ma;
   for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++){
           cin>>ch;
           a[i][j]='0';
           a[i][j]=ch-a[i][j];
       };
   cin>>nb>>mb;
   for (i=1;i<=nb;i++)
       for (j=1;j<=mb;j++){
            cin>>ch;
           b[i][j]='0';
           b[i][j]=ch-b[i][j];
       };
    for (i=1;i<=na;i++)
       for (j=1;j<=ma;j++)
           for (x=-i+1;x<=nb-i;x++)
               for (y=-j+1;y<=mb-j;y++){

                   if (a[i][j]*b[i+x][j+y]>max){
                      max=a[i][j]*b[i+x][j+y];
                      pas1=x; pas2=y;
                   };

               };
       cout<<pas1<<" "<<pas2;
 return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, n, m, x, y, i, j, k, l;
    string s;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        cin>>s;
        for(j = 0; j < m1; j++)
            a[i][j] = (int)(s[j]-'0');
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        cin>>s;
        for(j = 0; j < m2; j++)
            b[i][j] = (int)(s[j]-'0');
    }
    n = max(n1, n2);
    m = max(m1, m2);
    for(k = -n; k <= n; k++) //values that x can take
    {
        for(l = -m; l <= m; l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, x, y, i, j, k, l;
    string s;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        cin>>s;
        for(j = 0; j < m1; j++)
            a[i][j] = (int)(s[j]-'0');
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        cin>>s;
        for(j = 0; j < m2; j++)
            b[i][j] = (int)(s[j]-'0');
    }
    //0 <= i < n1, 0 <= i+x < n2: when i = 0, 0 <= x < n2 and when i = n1-1, -n1+1 <= x < n2-n1+1
    for(k = -n1+1; k < max(n2-n1+1, n2); k++) //values that x can take
    {
        for(l = -m1+1; l < max(m2-m1+1, m2); l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, n, m, x, y, i, j, k, l;
    string s;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        cin>>s;
        for(j = 0; j < m1; j++)
            a[i][j] = (int)(s[j]-'0');
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        cin>>s;
        for(j = 0; j < m2; j++)
            b[i][j] = (int)(s[j]-'0');
    }
    n = max(n1, n2);
    m = max(m1, m2);
    for(k = -n2; k <= n2; k++) //values that x can take DOUBT
    {
        for(l = -m2; l <= m2; l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, n, m, x, y, i, j, k, l;
    string s;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        cin>>s;
        for(j = 0; j < m1; j++)
            a[i][j] = (int)(s[j]-'0');
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        cin>>s;
        for(j = 0; j < m2; j++)
            b[i][j] = (int)(s[j]-'0');
    }
    n = max(n1, n2);
    m = max(m1, m2);
    for(k = n2-n1+1; k <= n2; k++) //values that x can take DOUBT
    {
        for(l = m2-m1+1; l <= m2; l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, n, m, x, y, i, j, k, l;
    string s;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        cin>>s;
        for(j = 0; j < m1; j++)
            a[i][j] = (int)(s[j]-'0');
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        cin>>s;
        for(j = 0; j < m2; j++)
            b[i][j] = (int)(s[j]-'0');
    }
    n = max(n1, n2);
    m = max(m1, m2);
    for(k = -n1; k < max(n2-n1+1, n2); k++) //values that x can take DOUBT
    {
        for(l = -m1; l < max(m2-m1+1, m2); l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


//In this problem you should carefully consider every shift  - N <  = x, y <  = N, count the answer and find the maximum value. The complexity of solution is O(N^4).
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<utility>
#include<sstream>
#include<iterator>

using namespace std;
int main()
{
    int n1, n2, m1, m2, maxx = 0, cnt = 0, n, m, x, y, i, j, k, l;
    cin>>n1>>m1;
    int a[n1][m1];
    for(i = 0; i < n1; i++)
    {
        for(j = 0; j < m1; j++)
            cin>>a[i][j];
    }
    cin>>n2>>m2;
    int b[n2][m2];
    for(i = 0; i < n2; i++)
    {
        for(j = 0; j < m2; j++)
            cin>>b[i][j];
    }

    n = max(n1, n2);
    m = max(m1, m2);

    for(k = -n; k <= n; k++) //values that x can take
    {
        for(l = -m; l <= m; l++) //values that y can take
        {
            cnt = 0;
            for(i = 0; i < n1; i++)
            {
                for(j = 0; j < m1; j++)
                {
                    if(i+k >= 0 and i+k < n2  and j+l >= 0 and j+l < m2)
                    {
                        if(a[i][j] == b[k+i][l+j] and a[i][j] == 1)
                            cnt++;
                    }
                }
            }
            if(cnt > maxx)
            {
                maxx = cnt;
                x = k;
                y = l;
            }
        }
    }

    cout<<x<<" "<<y<<endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    while(~scanf("%d%d",&na,&ma)){
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++)
    scanf("%1d",&a[i][j]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++)
    scanf("%1d",&b[i][j]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(ii-i>=0&&jj-j>=0&&ii-i<na&&jj-j<ma){
                cnt+=a[ii-i][jj-j]*b[ii][jj];
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(ii-i>=0&&jj-j>=0&&ii-i<nb&&jj-j<mb){
                cnt+=b[ii-i][jj-j]*a[ii][jj];
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int a[55][55],b[55][55];
int an,am,bn,bm;
int main()
{
    while(~scanf("%d%d",&an,&am)){
    for(int i=0;i<an;i++)
    for(int j=0;j<am;j++)
    scanf("%1d",&a[i][j]);
    scanf("%d%d",&bn,&bm);
    for(int i=0;i<bn;i++)
    for(int j=0;j<bm;j++)
    scanf("%1d",&b[i][j]);
    int maxn=-1;
    int ansx,ansy;
    for(int x=-an;x<bn;x++)
    for(int y=-am;y<bm;y++){
        int cnt=0;
        for(int i=0;i<an;i++)
        for(int j=0;j<am;j++){
            if(i+x>=0&&i+x<bn&&j+y>=0&&j+y<bm){
                cnt+=a[i][j]*b[i+x][j+y];
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            ansx=x,ansy=y;
        }
    }
    printf("%d %d\n",ansx,ansy);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    scanf("%d%d",&na,&ma);
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(ii-i>=0&&jj-i>=0&&ii-i<na&&jj-j<ma&&a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(ii-i>=0&&jj-i>=0&&ii-i<nb&&jj-j<mb&&b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    freopen("in.txt","r",stdin);
    while(~scanf("%d%d",&na,&ma)){
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(ii-i>=0&&jj-i>=0&&ii-i<na&&jj-j<ma&&a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(ii-i>=0&&jj-j>=0&&ii-i<nb&&jj-j<mb&&b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    scanf("%d%d",&na,&ma);
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    LL x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
            x=-x,y=-y;
        }
    }
    printf("%I64d %I64d\n",x,y);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    scanf("%d%d",&na,&ma);
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(b[ii-i][jj-j]==a[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    scanf("%d%d",&na,&nb);
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",--x,--y);
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define MAXN 1005

int ca,ra,cb,rb;
int a[60][60];
int b[60][60];
char buf[100];

int main()
{
    while(scanf("%d%d",&ra,&ca) != EOF)
    {
        getchar();
        for(int i=1;i<=ra;i++)
        {
            gets(buf);
            for(int j=1;j<=ca;j++)
            {
                if(buf[j-1]=='1')
                    a[i][j]=1;
                else
                    a[i][j]=0;
            }
        }
        scanf("%d%d",&rb,&cb);
        getchar();
        for(int i=1;i<=rb;i++)
        {
            gets(buf);
            for(int j=1;j<=cb;j++)
            {
                if(buf[j-1]=='1')
                    b[i][j]=1;
                else
                    b[i][j]=0;
            }
        }
    //  for(int i=1;i<=rb;i++)
    //      for(int j=1;j<=cb;j++)
    //          cout<<b[i][j]<<endl;
//  cout<<a[2][2]<<endl;
//  cout<<b[1][1]<<endl;
        int x,y,i,j;
        int ans=-100;
        int ans_x=-100,ans_y=-100;
        x=1-ra;
        //y=1-ca;
        for(;x<=rb-1;x++)
        {
            for(y=1-ca;y<=cb-1;y++)
            {
        //      cout<<"x="<<x<<" y="<<y<<endl;
                int tmp=0;
                for(i=1;i<=ra;i++)
                {
                    if(i+x<1)
                        continue;
                    if(i+x>rb )
                        break;
                //

cout<<"i="<<i<<"j="<<j<<endl;
                    for(j=1;j<=ca;j++)
                    {
                        if(j+y<1)
                            continue;
                        if(j+y>cb)
                            break;
                        tmp+=a[i][j]*b[i+x]

[j+y];
                    }
                }
                //cout<<"tmp="<<tmp<<endl;
                if(tmp>ans)
                {
                    ans=tmp;
                    ans_x=x;
                    ans_y=y;
                }
            }
        }
        printf("%d %d\n",ans_x,ans_y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    while(~scanf("%d%d",&na,&ma)){
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(ii-i>=0&&jj-i>=0&&ii-i<na&&jj-j<ma&&a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(ii-i>=0&&jj-j>=0&&ii-i<nb&&jj-j<mb&&b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

#define MAXN 1005

int ca,ra,cb,rb;
int a[60][60];
int b[60][60];
char buf[100];

int main()
{
    while(scanf("%d%d",&ra,&ca) != EOF)
    {
        getchar();
        for(int i=1;i<=ra;i++)
        {
            gets(buf);
            for(int j=1;j<=ca;j++)
            {
                if(buf[j-1]=='1')
                    a[i][j]=1;
                else
                    a[i][j]=0;
            }
        }
        scanf("%d%d",&rb,&cb);
        getchar();
        for(int i=1;i<=rb;i++)
        {
            gets(buf);
            for(int j=1;j<=cb;j++)
            {
                if(buf[j-1]=='1')
                    b[i][j]=1;
                else
                    b[i][j]=0;
            }
        }
        int x,y,i,j;
        int ans=-100;
        int ans_x=-100,ans_y=-100;
        x=1-ra;

        for(;x<=rb-1;x++)
        {
            for(y=1-ca;y<=cb-1;y++)
            {
                int tmp=0;
                for(i=1;i<=ra;i++)
                {
                    if(i+x<1)
                        continue;
                    if(i+x>rb )
                        break;
                    for(j=1;j<=ca;j++)
                    {
                        if(j+y<1)
                            continue;
                        if(j+y>cb)
                            break;
                        tmp+=a[i][j]*b[i+x][j+y];
                    }
                }
                if(tmp>ans)
                {
                    ans=tmp;
                    ans_x=x;
                    ans_y=y;
                }
            }
        }
        printf("%d %d\n",ans_x,ans_y);
    }
    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#define LL long long
using namespace std;
char a[55][55],b[55][55];
int na,ma,nb,mb;
int main()
{
    scanf("%d%d",&na,&ma);
    for(int i=0;i<na;i++)
        scanf("%s",a[i]);
    scanf("%d%d",&nb,&mb);
    for(int i=0;i<nb;i++)
    scanf("%s",b[i]);
    int x=0,y=0;
    int maxn=-1;
    for(int i=0;i<nb;i++)
    for(int j=0;j<mb;j++){
        int cnt=0;
        for(int ii=i;ii<nb;ii++)
        for(int jj=j;jj<mb;jj++){
            if(a[ii-i][jj-j]==b[ii][jj]&&b[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=i,y=j;
        }
    }
    for(int i=0;i<na;i++)
    for(int j=0;j<ma;j++){
        int cnt=0;
        for(int ii=i;ii<na;ii++)
        for(int jj=j;jj<ma;jj++){
            if(b[ii-i][jj-j]==a[ii][jj]&&a[ii][jj]=='1'){
                cnt++;
            }
        }
        if(maxn<cnt){
            maxn=cnt;
            x=-i,y=-j;
        }
    }
    printf("%d %d\n",x,y);
    return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}
	int ret = -INF, xx = -INF, yy = -INF;
	for(int x = -A; x <= A; x ++){
		for(int y = -B; y <= B; y ++){
			int sum = 0;
			for(int i = 0; i + x >= 0 && i < N && i + x < A; i ++){
				for(int j = 0; j + y >= 0 && j < M && j + y < B; j ++){
					sum += a[i][j] * b[i + x][y + j];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<" "<<endl;
	return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}

	int ret = -1, xx = -INF, yy = -INF;
	for(int x = -max(N, A); x <= max(N, A); x ++){
		for(int y = -max(M, B); y <= max(M, B); y ++){
			int sum = 0;
			for(int i = 0; i + x >= 0 && i < N && i + x < A; i ++){
				for(int j = 0; j + y >= 0 && j < M && j + y < B; j ++){
					sum += a[i][j] * b[i + x][j + y];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<endl;
	return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}
	int ret = -INF, xx = -INF, yy = -INF;
	for(int x = -100; x <= 100; x ++){
		for(int y = -100; y <= 100; y ++){
			int sum = 0;
			for(int i = 0; i + x >= 0 && i < N && i + x < A; i ++){
				for(int j = 0; j + y >= 0 && j < M && j + y < B; j ++){
					sum += a[i][j] * b[i + x][j + y];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<endl;
	return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}

	int ret = -1, xx = -INF, yy = -INF;
	for(int x = -max(N, A); x <= max(N, A); x ++){
		for(int y = -max(M, B); y <= max(M, B); y ++){
			int sum = 0;
			for(int i = 0; i < N && i + x < A; i ++){
				for(int j = 0; j < M && j + y < B; j ++){
					if(i + x < 0 || j + y < 0) continue;
					sum += a[i][j] * b[i + x][j + y];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<" "<<ret<<endl;
	return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}

	int ret = -1, xx = -INF, yy = -INF;
	for(int x = -A; x <= A; x ++){
		for(int y = -B; y <= B; y ++){
			int sum = 0;
			for(int i = 0; i + x >= 0 && i < N && i + x < A; i ++){
				for(int j = 0; j + y >= 0 && j < M && j + y < B; j ++){
					sum += a[i][j] * b[i + x][j + y];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<endl;
	return 0;
}


#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <iomanip>
#include <map>
#include <set>
#include <sstream>
#include <fstream>
#include <utility>
#include <string>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
#define REP(i,a) for(int i=0;i<a;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define SIZE(c) (int)c.size()
#define ALL(c) (c).begin(),(c).end()
typedef long long LL;
typedef pair<LL, LL> PII;
const int INF = 1000000000;
const int MAXN = 55;
int N, M, A, B;
int a[MAXN][MAXN], b[MAXN][MAXN];
int main() {
	//freopen("input.in", "r", stdin);
	cin>>N>>M;
	REP(i, N){
		REP(j, M){
			char c; cin>>c;
			if(c == '1') a[i][j] = 1;
			else a[i][j] = 0;
		}
	}
	cin>>A>>B;
	REP(i, A){
		REP(j, B){
			char c; cin>>c;
			if(c == '1') b[i][j] = 1;
			else b[i][j] = 0;
		}
	}

	int ret = -1, xx = -INF, yy = -INF;
	for(int x = -50; x <= 50; x ++){
		for(int y = -50; y <= 50; y ++){
			int sum = 0;
			for(int i = 0; i < N && i + x < A; i ++){
				for(int j = 0; j < M && j + y < B; j ++){
					if(i + x < 0 || j + y < 0) continue;
					sum += a[i][j] * b[i + x][j + y];
				}
			}
			if(sum > ret){
				ret = sum;
				xx = x;
				yy = y;
			}
		}
	}
	cout<<xx<<" "<<yy<<endl;
	return 0;
}


#include<stdio.h>
#include<string.h>

struct PNT
{
    int x,y;
}pnt[3000];

char a[51][51],b[51][51];
int main()
{
    int x,y,i,j,k;
    int n1,n2,m1,m2;
    int cas;
    while(scanf("%d%d",&n1,&m1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        cas=0;
      //  getchar();
        for(i=1;i<=n1;i++)
        {
             scanf("%s",a[i]);
             for(j=0;a[i][j];j++)
             if(a[i][j]=='1') {pnt[cas].x=i;pnt[cas].y=j+1; cas++;}

        }
        scanf("%d%d",&n2,&m2);
        //getchar();
        for(i=1;i<=n2;i++)
        {
              getchar();
              for(j=1;j<=m2;j++) scanf("%c",&b[i][j]);
        }
        int max=0;
        int cnt;
        int  pos1=0,pos2=0;
        //for(i=0;i<cas;i++) printf("%d %d\n",pnt[i].x,pnt[i].y);
        for(x=-50;x<=50;x++)
        {
            for(y=-50;y<=50;y++)
            {
                cnt=0;
                for(k=0;k<cas;k++)
                {
                    if(x+pnt[k].x<=0 || y+pnt[k].y<=0 || x+pnt[k].x>n2 || y+pnt[y].y>m2) continue;
                    if(b[x+pnt[k].x][y+pnt[k].y]=='1') cnt++;
                }
                if(cnt>=max) { max=cnt; pos1=x;pos2=y; }
            }
        }
        printf("%d %d\n",pos1,pos2);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>

struct PNT
{
    int x,y;
}pnt[3000];

char a[56][60],b[52][60];

int main()
{
    int x,y,i,j,k;
    int n1,n2,m1,m2;
    int cas;
    while(scanf("%d%d",&n1,&m1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        cas=0;
        for(i=1;i<=n1;i++)
        {
             scanf("%s",a[i]);
             for(j=0;a[i][j];j++)
             if(a[i][j]=='1') {pnt[cas].x=i;pnt[cas].y=j+1; cas++;}
        }
        scanf("%d%d",&n2,&m2);
        //getchar();

        for(i=1;i<=n2;i++)
        {
              getchar();
              for(j=1;j<=m2;j++) scanf("%c",&b[i][j]);
        }
        int max=0;
        int cnt;
        int  pos1=0,pos2=0;
        //for(i=0;i<cas;i++) printf("%d %d\n",pnt[i].x,pnt[i].y);
        for(x=-49;x<=49;x++)
        {
            for(y=-49;y<=49;y++)
            {
                cnt=0;
                for(k=0;k<cas;k++)
                {
                    if(x+pnt[k].x<=0 || y+pnt[k].y<=0 || x+pnt[k].x>n2 || y+pnt[y].y>m2) continue;
                    if(b[x+pnt[k].x][y+pnt[k].y]=='1') cnt++;
                }
                if(cnt>=max) { max=cnt; pos1=x;pos2=y; }
            }
        }
        printf("%d %d\n",pos1,pos2);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>

struct PNT
{
    int x,y;
}pnt[3000];

char a[51][51],b[51][51];
int main()
{
    int x,y,i,j,k;
    int n1,n2,m1,m2;
    int cas;
    while(scanf("%d%d",&n1,&m1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        cas=0;
      //  getchar();
        for(i=1;i<=n1;i++)
        {
             scanf("%s",a[i]);
             for(j=0;a[i][j];j++)
             if(a[i][j]=='1') {pnt[cas].x=i;pnt[cas].y=j+1; cas++;}

        }
        scanf("%d%d",&n2,&m2);
        //getchar();
        for(i=1;i<=n2;i++)
        {
              getchar();
              for(j=1;j<=m2;j++) scanf("%c",&b[i][j]);
        }
        int max=0;
        int cnt;
        int  pos1=0,pos2=0;
        //for(i=0;i<cas;i++) printf("%d %d\n",pnt[i].x,pnt[i].y);
        for(x=-50;x<=50;x++)
        {
            for(y=-50;y<=50;y++)
            {
                cnt=0;
                for(k=0;k<cas;k++)
                {
                    if(x+pnt[k].x<=0 || y+pnt[k].y<=0 || x+pnt[k].x>n2 || y+pnt[y].y>m2) continue;
                    if(b[x+pnt[k].x][y+pnt[k].y]) cnt++;
                }
                if(cnt>=max) { max=cnt; pos1=x;pos2=y; }
            }
        }
        printf("%d %d\n",pos1,pos2);
    }
    return 0;
}


#include<stdio.h>
#include<string.h>

struct PNT
{
    int x,y;
}pnt[3000];

char a[55][55],b[55][55];

int main()
{
    int x,y,i,j,k;
    int n1,n2,m1,m2;
    int cas;
    while(scanf("%d%d",&n1,&m1)!=EOF)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        cas=0;
        for(i=1;i<=n1;i++)
        {
             scanf("%s",a[i]);
             for(j=0;a[i][j];j++)
             if(a[i][j]=='1') {pnt[cas].x=i;pnt[cas].y=j+1; cas++;}
        }
        scanf("%d%d",&n2,&m2);
        //getchar();

        for(i=1;i<=n2;i++)
        {
              getchar();
              for(j=1;j<=m2;j++) scanf("%c",&b[i][j]);
        }
        int max=0;
        int cnt;
        int  pos1=0,pos2=0;
        //for(i=0;i<cas;i++) printf("%d %d\n",pnt[i].x,pnt[i].y);
        for(x=-49;x<=49;x++)
        {
            for(y=-49;y<=49;y++)
            {
                cnt=0;
                for(k=0;k<cas;k++)
                {
                    if(x+pnt[k].x<=0 || y+pnt[k].y<=0 || x+pnt[k].x>n2 || y+pnt[y].y>m2) continue;
                    if(b[x+pnt[k].x][y+pnt[k].y]=='1') cnt++;
                }
                if(cnt>=max) { max=cnt; pos1=x;pos2=y; }
            }
        }
        printf("%d %d\n",pos1,pos2);
    }
    return 0;
}


#include<iostream>
using namespace std;
int main()
{
    int** a=new int*[50];
    for(int i=0;i<50;i++)
    a[i]=new int[50];

    int**b=new int*[50];
    for(int i=0;i<50;i++)
    b[i]=new int[50];
    int na,ma;
    cin>>na>>ma;
    string str;

    for(int i=0;i<na;i++)
    {
        cin>>str;
        for(int j=0;j<ma;j++)
        a[i][j]=str[j];
    }
    int nb,mb;
    cin>>nb>>mb;
    for(int i=0;i<nb;i++)
    {
        cin>>str;
        for(int j=0;j<mb;j++)
        b[i][j]=str[j];
    }
    int x,y,max=0,f,l;
    for(x=-50;x<51;x++)
    {
        for(y=-50;y<51;y++)
        {
            int temp=0;
            for(int i=0;i<na;i++)
            {
                for(int j=0;j<ma;j++)
                {
                    if(i+x<nb && i+x>=0 && j+y<mb && j+y>=0)
                    temp+=a[i][j]*b[i+x][j+y];

                }
            }
            if(temp>=max)
            {
                max=temp;
                f=x;l=y;
            }
        }
    }
    cout<<f<<" "<<l;
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int** a=new int*[50];
    for(int i=0;i<50;i++)
    a[i]=new int[50];

    int**b=new int*[50];
    for(int i=0;i<50;i++)
    b[i]=new int[50];
    int na,ma;
    cin>>na>>ma;
    string str;

    for(int i=0;i<na;i++)
    {
        cin>>str;
        for(int j=0;j<ma;j++)
        a[i][j]=str[j];
    }
    int nb,mb;
    cin>>nb>>mb;
    for(int i=0;i<nb;i++)
    {
        cin>>str;
        for(int j=0;j<mb;j++)
        b[i][j]=str[j];
    }
    int x,y,max=0,f,l;
    for(x=-49;x<50;x++)
    {
        for(y=-49;y<50;y++)
        {
            int temp=0;
            for(int i=0;i<na;i++)
            {
                for(int j=0;j<ma;j++)
                {
                    if(i+x<nb && i+x>=0 && j+y<mb && j+y>=0)
                    temp+=a[i][j]*b[i+x][j+y];

                }
            }
            if(temp>max)
            {
                max=temp;
                f=x;l=y;
            }
        }
    }
    cout<<f<<" "<<l;
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int** a=new int*[50];
    for(int i=0;i<50;i++)
    a[i]=new int[50];

    int**b=new int*[50];
    for(int i=0;i<50;i++)
    b[i]=new int[50];
    int na,ma;
    cin>>na>>ma;
    string str;

    for(int i=0;i<na;i++)
    {
        cin>>str;
        for(int j=0;j<ma;j++)
        {if(str[j]=='1')
            a[i][j]=1;
         else a[i][j]=0;
        }
    }
    int nb,mb;
    cin>>nb>>mb;
    for(int i=0;i<nb;i++)
    {
        cin>>str;
        for(int j=0;j<mb;j++)
        {if(str[j]=='1') b[i][j]=1;
         else b[i][j]=0;
        }
    }
    int x,y,f,l;
    long long int max=0;
    for(x=-50;x<51;x++)
    {
        for(y=-50;y<51;y++)
        {
           long long int temp=0;
            for(int i=0;i<na;i++)
            {
                for(int j=0;j<ma;j++)
                {
                    if(i+x<nb && i+x>=0 && j+y<mb && j+y>=0)
                    temp+=a[i][j]*b[i+x][j+y];

                }
            }
            if(temp>=max)
            {
                max=temp;
                f=x;l=y;
            }
        }
    }
    cout<<f<<" "<<l;
    return 0;

}


#include<iostream>
using namespace std;
int main()
{
    int** a=new int*[50];
    for(int i=0;i<50;i++)
    a[i]=new int[50];

    int**b=new int*[50];
    for(int i=0;i<50;i++)
    b[i]=new int[50];
    int na,ma;
    cin>>na>>ma;
    string str;

    for(int i=0;i<na;i++)
    {
        cin>>str;
        for(int j=0;j<ma;j++)
        a[i][j]=str[j];
    }
    int nb,mb;
    cin>>nb>>mb;
    for(int i=0;i<nb;i++)
    {
        cin>>str;
        for(int j=0;j<mb;j++)
        b[i][j]=str[j];
    }
    int x,y,f,l;
    long long int max=0;
    for(x=-50;x<51;x++)
    {
        for(y=-50;y<51;y++)
        {
           long long int temp=0;
            for(int i=0;i<na;i++)
            {
                for(int j=0;j<ma;j++)
                {
                    if(i+x<nb && i+x>=0 && j+y<mb && j+y>=0)
                    temp+=a[i][j]*b[i+x][j+y];

                }
            }
            if(temp>=max)
            {
                max=temp;
                f=x;l=y;
            }
        }
    }
    cout<<f<<" "<<l;
    return 0;

}


#include<iostream>
using namespace std;
inline void merge_sort(int** ,int ,int );
inline void merge(int**,int,int,int);
inline int binary_search(int**,int,int,int);
int main()
{

    int n;
    cin>>n;
    int** a=new int*[100000];
    for(int i=0;i<100000;i++)
    a[i]=new int[2];
    int* b=new int[100000];
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0];
        a[i][1]=i+1;
    }
    merge_sort(a,0,n-1);
    int m,x;
    int temp=0,count1=0,count2=0;
    cin>>m;
    while(m--)
    {
    cin>>x;
    int flag=0;
    for(int i=0;i<temp;i++)
    {
        if(b[i]==x)
        {flag=1;break;}
    }
    if(flag==0)
    {
        count1+=binary_search(a,0,n-1,x);
        count2+=n-binary_search(a,0,n-1,x)+1;
    }
   }
   cout<<count1<<" "<<count2;
   return 0;
}

inline void merge_sort(int** a,int x,int y)
{
int middle;
if(x<y)
{
middle=(x+y)/2;
merge_sort(a,x,middle);
merge_sort(a,middle+1,y);
merge(a,x,middle,y);
}
}
inline void merge(int** a,int x,int y,int z)
{
     int f=x,m=y+1,l=z,i=x;
     int b[100000][2];
     while(f<=y && m<=z)
     {
           if(a[f][0]<=a[m][0])
           {
             b[i][0]=a[f][0];
             b[i][1]=a[f][1];
             f++;
           }
           else
           {
               b[i][0]=a[m][0];
               b[i][1]=a[m][1];
               m++;
           }
           i++;
     }
     if(f>y)
     {
         for(int j=m;j<=z;j++)
        {
           b[i][0]=a[j][0];
           b[i][1]=a[j][1];
           i++;
        }
     }
     else if(m>l)
     {
       for(int j=f;j<=y;j++)
       {
       b[i][0]=a[j][0];
       b[i][1]=a[j][1];
       i++;
       }
     }
     for(int k=x;k<=z;k++) {a[k][0]=b[k][0];a[k][1]=b[k][1];}

}
inline int binary_search(int**a,int x,int y,int k)
{
    int mid=(x+y)/2;
    if(a[mid][0]==k)
    return a[mid][1];
    else if(a[mid][0]>k && mid-1>=x)
    binary_search(a,x,mid-1,k);
    else if(a[mid][0]<k && mid+1<=y)
    binary_search(a,mid+1,y,k);
}


#include<iostream>
using namespace std;
int main()
{
    int** a=new int*[50];
    for(int i=0;i<50;i++)
    a[i]=new int[50];

    int**b=new int*[50];
    for(int i=0;i<50;i++)
    b[i]=new int[50];
    int na,ma;
    cin>>na>>ma;
    string str;

    for(int i=0;i<na;i++)
    {
        cin>>str;
        for(int j=0;j<ma;j++)
        a[i][j]=str[j];
    }
    int nb,mb;
    cin>>nb>>mb;
    for(int i=0;i<nb;i++)
    {
        cin>>str;
        for(int j=0;j<mb;j++)
        b[i][j]=str[j];
    }
    int x,y,max=0,f,l;
    for(x=-49;x<50;x++)
    {
        for(y=-49;y<50;y++)
        {
            int temp=0;
            for(int i=0;i<na;i++)
            {
                for(int j=0;j<ma;j++)
                {
                    if(i+x<nb && i+x>=0 && j+y<mb && j+y>=0)
                    temp+=a[i][j]*b[i+x][j+y];

                }
            }
            if(temp>=max)
            {
                max=temp;
                f=x;l=y;
            }
        }
    }
    cout<<f<<" "<<l;
    return 0;

}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-50; i<=50; i++){
      for(int j=-50; j<=50; j++){
         int cnt = 0;
         for(int k=0+i; k<n; k++){
            for(int l=0+j; l<m; l++){
               if(k-i >= 0 && n > k-i && l-j >= 0 && m > l-j){
                  if(field[k][l] == field2[k-i][l-j] && field[k][l] == '1'){
                     cnt++;
                  }
               }
            }
         }
         if(ans < cnt){
            ans = cnt;
            p.first = j, p.second = i;
         }
      }
   }

   cout << -1 * p.first << " " << -1 * p.second << endl;
   return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-50; i<=50; i++){
      for(int j=-50; j<=50; j++){
         int cnt = 0;
         for(int k=0+i; k<n; k++){
            for(int l=0+j; l<m; l++){
               if(field[k][l] == '1' && field[k][l] == field2[k-i][l-j] &&
                  k-i >= 0 && n > k-i && l-j >= 0 && m > l-j){
                  cnt++;
               }
            }
         }
         if(ans < cnt){
            ans = cnt;
            p.first = j, p.second = i;
         }
      }
   }

   cout << -1 * p.first << " " << -1 * p.second << endl;
   return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-50; i<=50; i++){
      for(int j=-50; j<=50; j++){
         int cnt = 0;
         int sum = 0;
         for(int k=0; k<n; k++){
            for(int l=0; l<m; l++){
               int ai = k;
               int aj = l;
               int bi = i + k;
               int bj = j + l;
               if(bi >= 0 && n2 > bi && bj >= 0 && m2 > bj){
                  sum += (field[ai][aj]-'0') * (field2[bi][bj]-'0');
                  cnt++;
               }
            }
         }
         if(ans < sum && cnt){
            ans = sum;
            p.first = i, p.second = j;
         }
      }
   }

   cout << p.first << " " << p.second << endl;
   return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-100; i<=100; i++){
      for(int j=-100; j<=100; j++){
         int cnt = 0;
         for(int k=0+i; k<n; k++){
            for(int l=0+j; l<m; l++){
               if(k-i >= 0 && n > k-i && l-j >= 0 && m > l-j){
                  if(field[k][l] == field2[k-i][l-j] && field[k][l] == '1'){
                     cnt++;
                  }
               }
            }
         }
         if(ans < cnt){
            ans = cnt;
            p.first = j, p.second = i;
         }
      }
   }

   cout << -1 * p.first << " " << -1 * p.second << endl;
   return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-50; i<=50; i++){
      for(int j=-50; j<=50; j++){
         int cnt = 0;
         for(int k=0+i; k<n; k++){
            for(int l=0+j; l<m; l++){
               if(k-i >= 0 && n > k-i && l-j >= 0 && m > l-j){
               if(field[k][l] == '1' && field[k][l] == field2[k-i][l-j]){
                  cnt++;
               }
            }
         }
         if(ans < cnt){
            ans = cnt;
            p.first = j, p.second = i;
         }
      }

   }
}

cout << -1 * p.first << " " << -1 * p.second << endl;
return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <stack>
#include <sstream>
#include <climits>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int MAX = 51;

int main(){
   int n,m,n2,m2;
   char field[MAX][MAX],field2[MAX][MAX];
   cin >> n >> m;
   cin.ignore();
   for(int i=0; i<n; i++)
      for(int j=0; j<m; j++) cin >> field[i][j];
   cin >> n2 >> m2;
   cin.ignore();

   for(int i=0; i<n2; i++)
      for(int j=0; j<m2; j++) cin >> field2[i][j];

   int ans = 0;
   pair<int,int>p;
   for(int i=-1000; i<=1000; i++){
      for(int j=-1000; j<=1000; j++){
         int cnt = 0;
         for(int k=0+i; k<n; k++){
            for(int l=0+j; l<m; l++){
               if(field[k][l] == '1' && field[k][l] == field2[k-i][l-j] &&
                  k-i >= 0 && n > k-i && l-j >= 0 && m > l-j){
                  cnt++;
               }
            }
         }
         if(ans < cnt){
            ans = cnt;
            p.first = j, p.second = i;
         }
      }
   }

   cout << -1 * p.first << " " << -1 * p.second << endl;
   return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
int f(int x,int y)
{
    int ans=0;
    for(int i=1,bi=i+x;i<=na&&bi<=nb;++i,++bi)
    for(int j=1,bj=j+y;j<=ma&&bj<=mb;++j,++bj)
    if(bi<=0||bj<=0) continue;
    else ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,Min(-na+1,-nb+1),Max(nb-1,na-1))
        ff(j,Min(-ma+1,-mb+1),Max(ma-1,mb-1))
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
bool in(int &x,int &y)
{
    return x>=1&&x<=nb&&y>=1&&y<=mb;
}
int f(int x,int y)
{
    int ans=0;
    for(int i=1,bi=i+x;i<=na;++i,++bi)
    for(int j=1,bj=j+y;j<=ma;++j,++bj)
    if(in(bi,bj))ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,Min(-na+1,-nb+1),Max(nb-1,na-1))
        ff(j,Min(-ma+1,-mb+1),Max(ma-1,mb-1))
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
int f(int x,int y)
{
    int ans=0;
    for(int i=Max(1,1-x),bi=i+x,z=Min(na,nb-x);i<=z;++i,++bi)
    for(int j=Max(1,1-y),bj=j+y,zz=Min(ma,mb-x);j<=zz;++j,++bj)
    ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,Min(-na+1,-nb+1),Max(nb-1,na-1))
        ff(j,Min(-ma+1,-mb+1),Max(ma-1,mb-1))
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
int f(int x,int y)
{
    int ans=0;
    for(int i=Max(1,1-x),bi=i+x,z=Min(na,nb-x);i<=z;++i,++bi)
    for(int j=Max(1,1-y),bj=j+y,zz=Min(ma,mb-x);j<=zz;++j,++bj)
    ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,-na+1,nb-1)
        ff(j,-ma+1,mb-1)
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
int f(int x,int y)
{
    int ans=0;
    for(int i=Max(1,1-x),bi=i+x,z=Min(na,nb-x);i<=z;++i,++bi)
    for(int j=Max(1,1-y),bj=j+y,zz=Min(ma,mb-x);j<=zz;++j,++bj)
    ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,-na+1,na-1)
        ff(j,-ma+1,ma-1)
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<sstream>
#include<string>
#include<climits>
#include<stack>
#include<set>
#include<bitset>
#include<cmath>
#include<deque>
#include<map>
#include<queue>
#define iinf 0x7f7f7f7f
#define linf 1000000000000000000LL
#define dinf 1e200
#define eps 1e-11
#define all(v) (v).begin(),(v).end()
#define sz(x)  x.size()
#define pb push_back
#define mp make_pair
#define lng long long
#define sqr(a) ((a)*(a))
#define pii pair<int,int>
#define pll pair<lng,lng>
#define pss pair<string,string>
#define pdd pair<double,double>
#define X first
#define Y second
#define pi 3.14159265359
#define ff(i,xi,n) for(int i=xi;i<=(int)(n);++i)
#define ffd(i,xi,n) for(int i=xi;i>=(int)(n);--i)
#define ffl(i,r) for(int i=head[r];i!=-1;i=edge[i].next)
#define ffe(i,r) for(_edge *i=head[r];i;i=i->next)
#define cc(i,j) memset(i,j,sizeof(i))
#define two(x)          ((lng)1<<(x))
#define lson l , mid , rt << 1
#define rson mid + 1 , r , rt << 1 | 1
#define mod  1073741824
#define pmod(x,y) (x%y+y)%y
using namespace std;
typedef vector<int>  vi;
typedef vector<string>  vs;
template<class T> inline void checkmax(T &x,T y)
{
    if(x<y) x=y;
}
template<class T> inline void checkmin(T &x,T y)
{
    if(x>y) x=y;
}
template<class T> inline T Min(T x,T y)
{
    return (x>y?y:x);
}
template<class T> inline T Max(T x,T y)
{
    return (x<y?y:x);
}
template<class T> T Abs(T a)
{
    return a>0?a:(-a);
}
template<class T> inline T lowbit(T n)
{
    return (n^(n-1))&n;
}
template<class T> inline int countbit(T n)
{
    return (n==0)?0:(1+countbit(n&(n-1)));
}
bool   a[51][51],b[51][51];
int na,ma,nb,mb;
int f(int x,int y)
{
    int ans=0;
    for(int i=1,bi=i+x;i<=na&&bi<=nb;++i,++bi)
    for(int j=1,bj=j+y;j<=ma&&bj<=mb;++j,++bj)
    ans+=(a[i][j]&b[bi][bj]);
    return ans;
}
char c;
int main()
{
    while(scanf("%d%d",&na,&ma)==2)
    {
        ff(i,1,na)
        {
            getchar();
            ff(j,1,ma)
            {
                c=getchar();
                a[i][j]=c-'0';
            }
        }
        scanf("%d%d",&nb,&mb);
        ff(i,1,nb)
        {
            getchar();
            ff(j,1,mb)
            {
                c=getchar();
                b[i][j]=c-'0';
            }
        }
        int mx,my,ans=-iinf,k;
        ff(i,Min(-na+1,-nb+1),Max(nb-1,na-1))
        ff(j,Min(-ma+1,-mb+1),Max(ma-1,mb-1))
        if(ans<(k=f(i,j))) ans=k,mx=i,my=j;
        printf("%d %d\n",mx,my);
    }
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    memset(mat_a, 0, sizeof(mat_a));
    memset(mat_b, 0, sizeof(mat_b));
    int ans_x = 0, ans_y = 0, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    for(int x = -n_a; x <= n_b; x++) {
        for(int y = -m_a; y <= m_b; y++) {
            int cnt = 0;
            for(int i = 1; i <= n_a; i++) {
                for(int j = 1; j <= m_a; j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[550][550];
int mat_b[550][550];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    memset(mat_a, 0, sizeof(mat_a));
    memset(mat_b, 0, sizeof(mat_b));
    int ans_x = 1, ans_y = 1, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    for(int x = -n_a; x <= n_b; x++) {
        for(int y = -m_a; y <= m_b; y++) {
            int cnt = 0;
            for(int i = 1; i <= n_a; i++) {
                for(int j = 1; j <= m_a; j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int ans_x = 0, ans_y = 0, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    for(int x = -n_a + 1; x <= n_b - 1; x++) {
        for(int y = -m_a + 1; y <= m_b - 1; y++) {
            int cnt = 0;
            for(int i = 1; i <= min(n_b - x, n_a); i++) {
                for(int j = 1; j <= min(m_b - y, m_a); j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int ans_x, ans_y, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    for(int x = -n_a + 1; x <= n_b - 1; x++) {
        for(int y = -m_a + 1; y <= m_b - 1; y++) {
            int cnt = 0;
            for(int i = 1; i <= min(n_b - x, n_a); i++) {
                for(int j = 1; j <= min(m_b - y, m_a); j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    memset(mat_a, 0, sizeof(mat_a));
    memset(mat_b, 0, sizeof(mat_b));
    int ans_x = 0, ans_y = 0, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    /*
    for(int x = -n_a; x <= n_b; x++) {
        for(int y = -m_a; y <= m_b; y++) {
            int cnt = 0;
            for(int i = 1; i <= n_a; i++) {
                for(int j = 1; j <= m_a; j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    */
    for(int x = -50; x <= 50; x++) {
        for(int y = -50; y <= 50; y++) {
            int cnt = 0;
            for(int i = 1; i <= n_a; i++) {
                for(int j = 1; j <= m_a; j++) {
                    if(i+x>=1 && i+x<=n_b && y+j>=1 && y+j<=m_b) cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int ans_x = 0, ans_y = 0, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    for(int x = -n_a; x <= n_b; x++) {
        for(int y = -m_a; y <= m_b; y++) {
            int cnt = 0;
            for(int i = 1; i <= min(n_b - x, n_a); i++) {
                for(int j = 1; j <= min(m_b - y, m_a); j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


/*
˼����
*/
#include<iostream>
#include<cstdlib>
#include<vector>
#include<map>
#include<cstring>
#include<set>
#include<string>
#include<algorithm>
#include<sstream>
#include<ctype.h>
#include<fstream>
#include<string.h>
#include<stdio.h>
#include<math.h>
#include<stack>
#include<queue>
#include<ctime>
//#include<conio.h>
using namespace std;

const int INF_MAX=0x7FFFFFFF;
const int INF_MIN=-(1<<30);

const double eps=1e-10;
const double pi=acos(-1.0);

#define pb push_back   //a.pb( )
#define chmin(a,b) ((a)<(b)?(a):(b))
#define chmax(a,b) ((a)>(b)?(a):(b))

template<class T> inline T gcd(T a,T b)//NOTES:gcd(
  {if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template<class T> inline T lcm(T a,T b)//NOTES:lcm(
  {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
int dir_4[4][2]={{0,1},{-1,0},{0,-1},{1,0}};
int dir_8[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};
//�£����£������ϣ��ϣ����ϣ��ң����¡�

//******* WATER ****************************************************************

int mat_a[55][55];
int mat_b[55][55];

int x, y;
int n_a, m_a;
int n_b, m_b;

void debug_1() {
    for(int i = 1; i <= n_a; i++) {
        for(int j = 1; j <= m_a; j++) {
            cout << mat_a[i][j] << " ";
        }
        cout << endl;
    }
}

void debug_2() {
    for(int i = 1; i <= n_b; i++) {
        for(int j = 1; j <= m_b; j++) {
            cout << mat_b[i][j] << " ";
        }
        cout << endl;
    }
}

int main() {
    int ans_x = 0, ans_y = 0, ans_cnt = INF_MIN;
    char tmp;
    scanf("%d%d", &n_a, &m_a);
    getchar();
    for(int i = 1; i <= n_a; i++) { for(int j = 1; j <= m_a; j++) { scanf("%c", &mat_a[i][j]); mat_a[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_1();
    //cout << "here" << endl;
    scanf("%d%d", &n_b, &m_b);
    getchar();
    for(int i = 1; i <= n_b; i++) { for(int j = 1; j <= m_b; j++) { scanf("%c", &mat_b[i][j]);  mat_b[i][j] -= '0';} scanf("%c", &tmp);}
    //debug_2();
    for(int x = -n_a + 1; x <= n_b - 1; x++) {
        for(int y = -m_a + 1; y <= m_b - 1; y++) {
            int cnt = 0;
            for(int i = 1; i <= min(n_b - x, n_a); i++) {
                for(int j = 1; j <= min(m_b - y, m_a); j++) {
                    cnt += mat_a[i][j]*mat_b[i+x][j+y];
                }
            }
            //cout << "x = " << x << " y = " << y << endl;
            //if(x == 1 && y == 1) cout << "cnt = " << cnt << endl;
            if(cnt > ans_cnt) {
                ans_cnt = cnt;
                ans_x = x;
                ans_y = y;
                //cout << "... " << cnt << endl;
            }
        }
    }
    printf("%d %d\n", ans_x, ans_y);
    return 0;
}


#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

const int SIZE = 51;
int na, ma, nb, mb;
bool A[SIZE][SIZE];
bool B[SIZE][SIZE];

bool input() {
    if ( ! ( cin >> na >> ma ) ) return false;
    for ( int i = 0; i < na; ++ i ) {
        for ( int j = 0; j < ma; ++ j ) {
            char c;
            cin >> c;
            A[i][j] = c == '1';
        }
    }
    cin >> nb >> mb;
    for ( int i = 0; i < nb; ++ i ) {
        for ( int j = 0; j < mb; ++ j ) {
            char c;
            cin >> c;
            B[i][j] = c == '1';
        }
    }
    return true;
}

void solve() {
    int res_r = 0, res_c = 0, max_cnt = 0;

    int n = min( na, nb ), m = min( ma, mb );
    for ( int rb = -n; rb + n - 1 < nb; ++ rb ) {
        for ( int cb = -m; cb + m - 1 < mb; ++ cb ) {
            for ( int ra = 0; ra + n - 1 < na; ++ ra ) {
                for ( int ca = 0; ca + m - 1 < ma; ++ ca ) {
                    int cnt = 0;
                    for ( int i = 0; i < n; ++ i ) {
                        for ( int j = 0; j < m; ++ j ) {
                            if ( rb+i >= 0 && rb+i < nb && cb+j >= 0 && cb+j < mb ) {
                                if ( A[ra+i][ca+j] && B[rb+i][cb+j] ) {
                                    cnt ++;
                                }
                            }
                        }
                    }
                    if ( cnt > max_cnt ) {
                        res_r = rb - ra;
                        res_c = cb - ca;
                        max_cnt = cnt;
                    }
                }
            }
        }
    }

    cout << res_r << " " << res_c << endl;
}

int main() {
    while ( input() ) {
        solve();
    }
    return 0;
}