#include <bits/stdc++.h>
using namespace std;
#define ll long long

struct Tragac
{
    int r,c,v;

    bool operator < (Tragac other)
    {
        return v > other.v;
    }
};

Tragac tragac[1005];
int matr[1005][1005];
int visited[1005][1005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    memset(matr,31,sizeof(matr));
    memset(visited,-1,sizeof(visited));

    int n,r,c;
    cin >> r >> c >> n;
    queue<pair<int,int>> q[1005];
    int cnt=n;
    for(int i = 0;i<n;i++)
    {
        cin >> tragac[i].r >> tragac[i].c >> tragac[i].v;
        tragac[i].r--;
        tragac[i].c--;
    }

    sort(tragac,tragac+n);

    for(int i = 0;i<n;i++)
    {
        q[i].push({tragac[i].r,tragac[i].c});
    }

    for(int i = 0;i<n;i++)
    {
        int cnt = 0;
        matr[q[i].front().first][q[i].front().second] = 0;
        while(!q[i].empty())
        {
            cnt++;
            for(int j = 0;j<tragac[i].v;j++)
            {
                int s = q[i].size();
                for(int x = 0;x<s;x++)
                {
                    pair<int,int> pom = q[i].front();
                    q[i].pop();

                    int red[4] = {0,1,0,-1};
                    int kol[4] = {1,0,-1,0};
                    for(int k = 0;k<4;k++)
                    {
                        int row = pom.first+red[k];
                        int col = pom.second+kol[k];

                        if(row >= 0 && row < r && col >= 0 && col < c && cnt <= matr[row][col] && visited[row][col] != i)
                        {
                            visited[row][col] = i;
                            matr[row][col] = cnt;
                            q[i].push({row,col});
                        }
                    }
                }
            }

        }
    }

    int Max = -1;
    int ansR,ansC;
    for(int i = 0;i<r;i++)
    {
        for(int j =0 ;j<c;j++)
        {
          //  cout << matr[i][j] << " ";
            if(matr[i][j] > Max)
            {
                Max  = matr[i][j];
                ansR = i+1;
                ansC = j+1;
            }
        }
        //cout << "\n";
    }

    cout << ansR << " " << ansC;

    return 0;
}