#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define pell pair<ll,ll>
#define pei pair<int,int>
#define dpe pair<ll,pe>
#define x first
#define y second
const ll maxn=3e5+10,maxmask=(1<<8);
int n,m,a[maxn][10],vt[maxmask];
pei ans;
bool check(int x)
{
for(int i=0;i<(1<<n);i++)
vt[i]=0;
for(int i=1;i<=m;i++)
{
int tmp=0;
for(int j=1;j<=n;j++)
{
if(a[i][j]>=x)
{
tmp+=(1<<(j-1));
}
}
vt[tmp]=i;
}
for(int i=0;i<(1<<n);i++)
{
for(int j=0;j<(1<<n);j++)
{
if((vt[i]&&vt[j])&&((i|j)==(1<<n)-1))
{
ans={vt[i],vt[j]};
return 1;
}
}
}
return 0;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
if(fopen("111.INP","r"))
{
freopen("111.INP","r",stdin);
freopen("111.OUT","w",stdout);
}
cin>>m>>n;
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
cin>>a[i][j];
}
}
int l=0,r=1e9;
while(l<=r)
{
int mid=(l+r)/2;
if(check(mid)) l=mid+1;
else r=mid-1;
}
cout<<ans.x<<" "<<ans.y;
}
1517A - Sum of 2050 | 620A - Professor GukiZ's Robot |
1342A - Road To Zero | 1520A - Do Not Be Distracted |
352A - Jeff and Digits | 1327A - Sum of Odd Integers |
1276A - As Simple as One and Two | 812C - Sagheer and Nubian Market |
272A - Dima and Friends | 1352C - K-th Not Divisible by n |
545C - Woodcutters | 1528B - Kavi on Pairing Duty |
339B - Xenia and Ringroad | 189A - Cut Ribbon |
1182A - Filling Shapes | 82A - Double Cola |
45A - Codecraft III | 1242A - Tile Painting |
1663E - Are You Safe | 1663D - Is it rated - 3 |
1311A - Add Odd or Subtract Even | 977F - Consecutive Subsequence |
939A - Love Triangle | 755A - PolandBall and Hypothesis |
760B - Frodo and pillows | 1006A - Adjacent Replacements |
1195C - Basketball Exercise | 1206A - Choose Two Numbers |
1438B - Valerii Against Everyone | 822A - I'm bored with life |