#include <bits/stdc++.h>
#define dbg() cerr <<
#define name(x) (#x) << ": " << (x) << ' ' <<

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, m; cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> a[i][j];
    }
  }
  vector<int> row(n), col(m);
  vector<vector<int>> sum(2, vector<int>(max(n, m)));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      sum[0][i] += a[i][j];
      sum[1][j] += a[i][j];
    }
  }
  while (true) {
    tuple<int, int, int> minn = make_tuple((int)1e9, -1, -1);
    for (int i = 0; i < n; ++i) {
      minn = min(minn, make_tuple(sum[0][i], i, 0));
    }
    for (int i = 0; i < m; ++i) {
      minn = min(minn, make_tuple(sum[1][i], i, 1));
    }
    if (get<0>(minn) > 0) break;
    int idx, type; tie(ignore, idx, type) = minn;
    if (type) {
      for (int i = 0; i < n; ++i) {
        int val = a[i][idx];
        if (row[i] ^ col[idx]) val = -val;
        sum[0][i] -= 2 * val;
      }
      col[idx] = 1 ^ col[idx];
      sum[1][idx] = -sum[1][idx];
    } else {
      for (int i = 0; i < m; ++i) {
        int val = a[idx][i];
        if (row[idx] ^ col[i]) val = -val;
        sum[1][i] -= 2 * val;
      }
      row[idx] = 1 ^ row[idx];
      sum[0][idx] = -sum[0][idx];
    }
  }
  cout << count(row.begin(), row.end(), 1) << ' ';
  for (int i = 0; i < n; ++i) if (row[i]) cout << 1 + i << ' ';
  cout << '\n';
  cout << count(col.begin(), col.end(), 1) << ' ';
  for (int i = 0; i < m; ++i) if (col[i]) cout << 1 + i << ' ';
  cout << endl;
}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#define N 110
using namespace std;

int n,m;
int a[N][N];
int h[N],l[N],markh[N],markl[N];

int findh()
{
	for (int i=1;i<=n;i++)
	 if (h[i]<0)  return i;
	return 0;
}

int findl()
{
	for (int i=1;i<=m;i++)
	 if (l[i]<0)  return i;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	{
		scanf("%d",&a[i][j]);
		h[i]+=a[i][j];
		l[j]+=a[i][j];
	}
	int t=0,t1=0;
	while ((t=findh())||(t1=findl()))
	{
		if (t)
		{
			markh[t]++;
			int sum=0;
			for (int i=1;i<=m;i++)
			{
				int k=-a[t][i];
				l[i]=l[i]-a[t][i]+k;
				a[t][i]=k;
				sum+=k;
			}
			h[t]=sum;
			}
		else
		{
			markl[t1]++; int sum=0;
			for (int i=1;i<=n;i++)
			{
				int k=-a[i][t1];
				h[i]=h[i]-a[i][t1]+k;
				a[i][t1]=k; sum+=k;
			}
			l[t1]=sum;
		}
	}

	int num=0,num1=0;
	for (int i=1;i<=n;i++)
	{
		if (markh[i]&1) num++;
		else markh[i] = 0;
	}

	printf("%d ",num);

	for (int i=1;i<=n;i++)
		if (markh[i])  printf("%d ",i);
	printf("\n");

	for (int i=1;i<=m;i++)
	{
		if (markh[i]&1) num1++;
		else markh[i] = 0;
	}
	printf("%d ",num1);

	for (int i=1;i<=m;i++)
		if (markl[i])  printf("%d ",i);
	printf("\n");

}


#include <iostream>
#include <cstring>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <cmath>
#define N 110
using namespace std;

int n,m;
int a[N][N];
int h[N],l[N],markh[N],markl[N];

int findh()
{
	for (int i=1;i<=n;i++)
	 if (h[i]<0)  return i;
	return 0;
}

int findl()
{
	for (int i=1;i<=m;i++)
	 if (l[i]<0)  return i;
	return 0;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	{
		scanf("%d",&a[i][j]);
		h[i]+=a[i][j];
		l[j]+=a[i][j];
	}
	int t=0,t1=0;
	while ((t=findh())||(t1=findl()))
	{
		if (t)
		{
			markh[t]++;
			int sum=0;
			for (int i=1;i<=m;i++)
			{
				int k=-a[t][i];
				l[i]=l[i]-a[t][i]+k;
				a[t][i]=k;
				sum+=k;
			}
			h[t]=sum;
			}
		else
		{
			markl[t1]++; int sum=0;
			for (int i=1;i<=n;i++)
			{
				int k=-a[i][t1];
				h[i]=h[i]-a[i][t1]+k;
				a[i][t1]=k; sum+=k;
			}
			l[t1]=sum;
		}
	}

	int num=0,num1=0;
	for (int i=1;i<=n;i++)
		if (markh[i]&1) num++;
	printf("%d ",num);

	for (int i=1;i<=n;i++)
		if (markh[i]&1)  printf("%d ",i);
	printf("\n");

	for (int i=1;i<=m;i++)
		if (markl[i]&1)  num1++;
	printf("%d ",num1);

	for (int i=1;i<=m;i++)
		if (markl[i]&1)  printf("%d ",i);
	printf("\n");

}


//lxrtxdy!
//62ms  0KB
#include <cstdio>
#include <cctype>
#define gc() getchar()
typedef long long LL;
const int N=105;

int A[N][N];
bool x[N],y[N];

inline int read()
{
    int now=0,f=1;register char c=gc();
    for(;!isdigit(c);c=='-'&&(f=-1),c=gc());
    for(;isdigit(c);now=now*10+c-48,c=gc());
    return now*f;
}
void Print(bool *a,int n)
{
    int t=0;
    for(int i=1; i<=n; ++i) t+=a[i];
    printf("%d ",t);
    for(int i=1; i<=n; ++i) a[i]&&printf("%d ",i);
    putchar('\n');
}

int main()
{
    const int n=read(),m=read();
    for(int i=1; i<=n; ++i)
        for(int j=1; j<=m; ++j) A[i][j]=read();
    for(; ; )
    {
        bool ok=1;
        for(int i=1; i<=n; ++i)
        {
            int s=0;
            for(int j=1; j<=m; ++j) s+=x[i]^y[j]?-A[i][j]:A[i][j];
            if(s<0) x[i]^=1, ok=0;
        }
        for(int j=1; j<=m; ++j)
        {
            int s=0;
            for(int i=1; i<=n; ++i) s+=x[i]^y[j]?-A[i][j]:A[i][j];
            if(s<0) y[j]^=1, ok=0;
        }
        if(ok) break;
    }
    Print(x,n), Print(y,m);

    return 0;
}
//orzlxr!


#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define point pair<double,double>
#define pl pair<ll,ll>
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
using namespace std;

int S[2][100];
int G[100][100],m,n;
void DO(vi & V){
	set<int> S;
	for(int x : V)
		if(S.find(x) != S.end()) S.erase(x);
		else S.insert(x);
	V.clear();
	for(int x : S) V.pb(x);
}

int main(){
	scanf("%d %d",&m,&n);
	queue<pi> q;
	loop(i,m) loop(j,n) {
		scanf("%d",&G[i][j]);
		S[1][j] += G[i][j];
		S[0][i] += G[i][j];
	}
	loop(i,m) if(S[0][i] < 0) q.push(mp(i,0));
	loop(i,n) if(S[1][i] < 0) q.push(mp(i,1));
	vi row,col;
	while(!q.empty()){
		int u = q.front().xx,type = q.front().yy; q.pop();
		if(S[type][u] >= 0) continue;
		S[type][u] *= -1;
		if(type){
			col.pb(u+1);
			loop(i,m) {
				S[0][i] -= 2*G[i][u];
				G[i][u] *= -1;
				if(S[0][i] < 0) q.push(mp(i,0));
			}
		}
		else {
			row.pb(u+1);
			loop(i,n){
				S[1][i] -= 2*G[u][i];
				G[u][i] *= -1;
				if(S[1][i] < 0) q.push(mp(i,1));
			}
		}
	}
	DO(row); DO(col);
	printf("%d",sz(row));
	for(int x : row) printf(" %d",x);
	printf("\n%d",sz(col));
	for(int x : col) printf(" %d",x);
	puts("");

	return 0;
}


#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define point pair<double,double>
#define pl pair<ll,ll>
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
using namespace std;

int S[2][100];
int G[100][100],m,n;
void DO(vi & V){
	set<int> S;
	for(int x : V)
		if(S.find(x) == S.end()) S.erase(x);
		else S.insert(x);
	V.clear();
	for(int x : S) V.pb(x);
}

int main(){
	scanf("%d %d",&m,&n);
	queue<pi> q;
	loop(i,m) loop(j,n) {
		scanf("%d",&G[i][j]);
		S[1][j] += G[i][j];
		S[0][i] += G[i][j];
	}
	loop(i,m) if(S[0][i] < 0) q.push(mp(i,0));
	loop(i,n) if(S[1][i] < 0) q.push(mp(i,1));
	vi row,col;
	while(!q.empty()){
		int u = q.front().xx,type = q.front().yy; q.pop();
		if(S[type][u] >= 0) continue;
		S[type][u] *= -1;
		if(type){
			col.pb(u+1);
			loop(i,m) {
				S[0][i] -= 2*G[i][u];
				G[i][u] *= -1;
				if(S[0][i] < 0) q.push(mp(i,0));
			}
		}
		else {
			row.pb(u+1);
			loop(i,n){
				S[1][i] -= 2*G[u][i];
				G[u][i] *= -1;
				if(S[1][i] < 0) q.push(mp(i,1));
			}
		}
	}
	DO(row); DO(col);
	printf("%d",sz(row));
	for(int x : row) printf(" %d",x);
	printf("\n%d",sz(col));
	for(int x : col) printf(" %d",x);
	puts("");

	return 0;
}


#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define point pair<double,double>
#define pl pair<ll,ll>
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
using namespace std;

int S[2][100];
int G[100][100],m,n;

int main(){
	scanf("%d %d",&m,&n);
	queue<pi> q;
	loop(i,m) loop(j,n) {
		scanf("%d",&G[i][j]);
		S[1][j] += G[i][j];
		S[0][i] += G[i][j];
	}
	loop(i,m) if(S[0][i] < 0) q.push(mp(i,0));
	loop(i,n) if(S[1][i] < 0) q.push(mp(i,1));
	vi row,col;
	while(!q.empty()){
		int u = q.front().xx,type = q.front().yy; q.pop();
		if(S[type][u] >= 0) continue;
		S[type][u] *= -1;
		if(type){
			col.pb(u+1);
			loop(i,m) {
				S[0][i] -= 2*G[i][u];
				G[i][u] *= -1;
				if(S[0][i] < 0) q.push(mp(i,0));
			}
		}
		else {
			row.pb(u+1);
			loop(i,n){
				S[1][i] -= 2*G[u][i];
				G[u][i] *= -1;
				if(S[1][i] < 0) q.push(mp(i,1));
			}
		}
	}
	printf("%d",sz(row));
	for(int x : row) printf(" %d",x);
	printf("\n%d",sz(col));
	for(int x : col) printf(" %d",x);
	puts("");

	return 0;
}


#include <bits/stdc++.h>
#define loop(i,n) for(int i = 0;i < (n);i++)
#define range(i,a,b) for(int i = (a);i <= (b);i++)
#define all(A) A.begin(),A.end()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define sz(A) ((int)A.size())
#define vi vector<int>
#define vl vector<long long>
#define vd vector<double>
#define vp vector<pair<int,int> >
#define ll long long
#define pi pair<int,int>
#define point pair<double,double>
#define pl pair<ll,ll>
#define popcnt(x) __builtin_popcount(x)
#define LSOne(x) ((x) & (-(x)))
#define xx first
#define yy second
#define PQ priority_queue
#define print(A,t) cerr << #A << ": "; copy(all(A),ostream_iterator<t>(cerr," " )); cerr << endl
#define prp(p) cerr << "(" << (p).first << " ," << (p).second << ")";
#define prArr(A,n,t)  cerr << #A << ": "; copy(A,A + n,ostream_iterator<t>(cerr," " )); cerr << endl
#define PRESTDIO() cin.tie(0),cerr.tie(0),ios_base::sync_with_stdio(0)
using namespace std;

int S[2][100];
int G[100][100],m,n;
void DO(vi & V){
	sort(all(V));
	V.resize(unique(all(V)) - V.begin());
}

int main(){
	scanf("%d %d",&m,&n);
	queue<pi> q;
	loop(i,m) loop(j,n) {
		scanf("%d",&G[i][j]);
		S[1][j] += G[i][j];
		S[0][i] += G[i][j];
	}
	loop(i,m) if(S[0][i] < 0) q.push(mp(i,0));
	loop(i,n) if(S[1][i] < 0) q.push(mp(i,1));
	vi row,col;
	while(!q.empty()){
		int u = q.front().xx,type = q.front().yy; q.pop();
		if(S[type][u] >= 0) continue;
		S[type][u] *= -1;
		if(type){
			col.pb(u+1);
			loop(i,m) {
				S[0][i] -= 2*G[i][u];
				G[i][u] *= -1;
				if(S[0][i] < 0) q.push(mp(i,0));
			}
		}
		else {
			row.pb(u+1);
			loop(i,n){
				S[1][i] -= 2*G[u][i];
				G[u][i] *= -1;
				if(S[1][i] < 0) q.push(mp(i,1));
			}
		}
	}
	DO(row); DO(col);
	printf("%d",sz(row));
	for(int x : row) printf(" %d",x);
	printf("\n%d",sz(col));
	for(int x : col) printf(" %d",x);
	puts("");

	return 0;
}


#include <cstdio>
#define reg register
using namespace std;

int n, m, a[105][105], hang[105], lie[105], anshang[100005], hanglen, lielen, anslie[100005];

struct node{
    int f, x;
};

inline node check(){
    node q;
    for(reg int i = 1; i <= n; i++){
        if(hang[i] < 0){
            q.f = 1;
            q.x = i;
            return q;
        }
    }
    for(reg int j = 1; j <= m; j++){
        if(lie[j] < 0){
            q.f = 2;
            q.x = j;
            return q;
        }
    }
    q.f = q.x = 0;
    return q;
}

int main(){
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; i++){
        for(reg int j = 1; j <= m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(reg int i = 1; i <= n; i++){
        for(reg int j = 1; j <= m; j++){
            hang[i] += a[i][j];
        }
    }
    for(reg int j = 1; j <= m; j++){
        for(reg int i = 1; i <= n; i++){
            lie[j] += a[i][j];
        }
    }
    while(1){
        node ne = check();
        if(ne.f){
            if(ne.f == 1){
                hanglen ++;
                anshang[hanglen] = ne.x;
                for(reg int j = 1; j <= m; j++){
                    lie[j] -= 2 * a[ne.x][j];
                    a[ne.x][j] = -a[ne.x][j];
                }
                hang[ne.x] = -hang[ne.x];
            }
            else {
                lielen ++;
                anslie[lielen] = ne.x;
                for(reg int i = 1; i <= n; i++){
                    hang[i] -= 2 * a[i][ne.x];
                    a[i][ne.x] = -a[i][ne.x];
                }
                lie[ne.x] = -lie[ne.x];
            }
        }
        else
            break;
    }
    printf("%d", hanglen);
    for(reg int i = 1; i <= hanglen; i++){
        printf(" %d", anshang[i]);
    }
    printf("\n%d", lielen);
    for(reg int j = 1; j <= lielen; j++){
        printf(" %d", anslie[j]);
    }
    printf("\n");
    return 0;
}


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

const int N=110;

int n,m,A[N][N],row[N],col[N];
vector<int> ans1;
vector<int> ans2;

int main() {
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%d",&A[i][j]);

	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			row[i]+=A[i][j];
	for(int j=1;j<=m;j++)
		for(int i=1;i<=n;i++)
			col[j]+=A[i][j];
	/*for(int i=1;i<=n;i++)  cout<<row[i]<<' '; cout<<endl;
	for(int j=1;j<=m;j++)  cout<<col[j]<<' '; */

	bool flag;
	do {
		flag=0;
		for(int i=1;i<=n;i++) {
			if(row[i]<0) {
				ans1.push_back(i);
				flag=1;
				for(int j=1;j<=m;j++) {
					col[j]-=A[i][j]*2;
					A[i][j]=-A[i][j];
				}
				row[i]=-row[i];
			}
		}
		for(int j=1;j<=m;j++) {
			if(col[j]<0) {
				flag=1;
				ans2.push_back(j);
				for(int i=1;i<=n;i++) {
					row[i]-=A[i][j]*2;
					A[i][j]=-A[i][j];
				}
				col[j]=-col[j];
			}
		}
	} while(flag);
	cout<<ans1.size()<<' ';
	for(int i=0;i<ans1.size();i++) cout<<ans1[i]<<' ';
	cout<<endl<<ans2.size()<<' ';
	for(int i=0;i<ans2.size();i++) cout<<ans2[i]<<' ';
}


#include <cstdio>
#include <algorithm>
#define reg register
using namespace std;

int n, m, a[105][105], hang[105], lie[105], anshang[100005], hanglen, lielen, anslie[100005];

struct node{
    int f, x;
};

inline node check(){
    node q;
    for(reg int i = 1; i <= n; i++){
        if(hang[i] < 0){
            q.f = 1;
            q.x = i;
            return q;
        }
    }
    for(reg int j = 1; j <= m; j++){
        if(lie[j] < 0){
            q.f = 2;
            q.x = j;
            return q;
        }
    }
    q.f = q.x = 0;
    return q;
}

int main(){
    scanf("%d%d", &n, &m);
    for(reg int i = 1; i <= n; i++){
        for(reg int j = 1; j <= m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(reg int i = 1; i <= n; i++){
        for(reg int j = 1; j <= m; j++){
            hang[i] += a[i][j];
        }
    }
    for(reg int j = 1; j <= m; j++){
        for(reg int i = 1; i <= n; i++){
            lie[j] += a[i][j];
        }
    }
    while(1){
        node ne = check();
        if(ne.f){
            if(ne.f == 1){
                hanglen ++;
                anshang[hanglen] = ne.x;
                for(reg int j = 1; j <= m; j++){
                    lie[j] -= 2 * a[ne.x][j];
                    a[ne.x][j] = -a[ne.x][j];
                }
                hang[ne.x] = -hang[ne.x];
            }
            else {
                lielen ++;
                anslie[lielen] = ne.x;
                for(reg int i = 1; i <= n; i++){
                    hang[i] -= 2 * a[i][ne.x];
                    a[i][ne.x] = -a[i][ne.x];
                }
                lie[ne.x] = -lie[ne.x];
            }
        }
        else
            break;
    }
    sort(anshang + 1, anshang + 1 + hanglen);
    sort(anslie + 1, anslie + 1 + lielen);
    int tot = 0, iop = 0;
    for(reg int i = 1; i <= hanglen; i++){
        if(anshang[i] != anshang[i - 1]){
            if(tot % 2 == 1)
                iop ++;
            tot = 1;
        }
        else {
            tot ++;
        }
    }
    if(tot % 2 == 1)
        iop ++;
    printf("%d", iop);
    tot = 0;
    for(reg int i = 1; i <= hanglen; i++){
        if(anshang[i] != anshang[i - 1]){
            if(tot % 2 == 1)
                printf(" %d", anshang[i - 1]);
            tot = 1;
        }
        else {
            tot ++;
        }
    }
    if(tot % 2 == 1)
        printf(" %d", anshang[hanglen]);
    tot = 0, iop = 0;
    for(reg int i = 1; i <= lielen; i++){
        if(anslie[i] != anslie[i - 1]){
            if(tot % 2 == 1)
                iop ++;
            tot = 1;
        }
        else {
            tot ++;
        }
    }
    if(tot % 2 == 1)
        iop ++;
    printf("\n%d", iop);
    tot = 0;
    for(reg int i = 1; i <= lielen; i++){
        if(anslie[i] != anslie[i - 1]){
            if(tot % 2 == 1)
                printf(" %d", anslie[i - 1]);
            tot = 1;
        }
        else {
            tot ++;
        }
    }
    if(tot % 2 == 1)
        printf(" %d\n", anslie[lielen]);
    return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>
void rd(T &x)
{
	int f = 1;
    x = 0;
    char c;
    while (c = getchar(), c < 48) if (c == '-') f = -1;
    do
    	x = (x << 3) + (x << 1) + (c ^ 48);
    while (c = getchar(), c > 47 && c < 58);
	x *= f;
}
const int N = 105;
int n, m, a[N][N], sumx[N], sumy[N], ansx[N], ansy[N], totx, toty;
int ckx()
{
	for (int i = 1; i <= n; i++)
		if (sumx[i] < 0)
			return i;
	return 0;
}
int cky()
{
	for (int i = 1; i <= m; i++)
		if (sumy[i] < 0)
			return i;
	return 0;
}
int main()
{
	rd(n), rd(m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			rd(a[i][j]), sumx[i] += a[i][j], sumy[j] += a[i][j];
	int xx = ckx(), yy = cky();
	while (xx || yy)
	{
		if (xx)
		{
			++ansx[xx];
			sumx[xx] = 0;
			for (int i = 1; i <= m; i++)
			{
				int v = -a[xx][i];
				sumy[i] += v - a[xx][i];
				a[xx][i] = v;
				sumx[xx] += v;
			}
		}
		else
		{
			++ansy[yy];
			sumy[yy] = 0;
			for (int i = 1; i <= n; i++)
			{
				int v = -a[i][yy];
				sumx[i] += v - a[i][yy];
				a[i][yy] = v;
				sumy[yy] += v;
			}
		}
		xx = ckx(), yy = cky();
	}
	for (int i = 1; i <= n; totx += (ansx[i] & 1), i++);
	for (int i = 1; i <= m; toty += (ansy[i] & 1), i++);
	printf ("%d ", totx);
	for (int i = 1; i <= n; i++)
		if (ansx[i] & 1)
			printf ("%d ", i);
	printf ("\n%d ", toty);
	for (int i = 1; i <= m; i++)
		if (ansy[i] & 1)
			printf ("%d ", i);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>
void rd(T &x)
{
	int f = 1;
    x = 0;
    char c;
    while (c = getchar(), c < 48) if (c == '-') f = -1;
    do
    	x = (x << 3) + (x << 1) + (c ^ 48);
    while (c = getchar(), c > 47 && c < 58);
	x *= f;
}
const int N = 105;
int n, m, a[N][N], sumx[N], sumy[N], ansx[N], ansy[N], totx, toty;
int ckx()
{
	for (int i = 1; i <= n; i++)
		if (sumx[i] < 0)
			return i;
	return 0;
}
int cky()
{
	for (int i = 1; i <= m; i++)
		if (sumy[i] < 0)
			return i;
	return 0;
}
int main()
{
	rd(n), rd(m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			rd(a[i][j]), sumx[i] += a[i][j], sumy[j] += a[i][j];
	int xx = ckx(), yy = cky();
	while (xx || yy)
	{
		if (xx)
		{
			++ansx[xx];
			sumx[xx] = 0;
			for (int i = 1; i <= m; i++)
			{
				int v = -a[xx][i];
				sumy[i] += v - a[xx][i];
				a[xx][i] = v;
				sumx[xx] += v;
			}
		}
		if (yy)
		{
			++ansy[yy];
			sumy[yy] = 0;
			for (int i = 1; i <= n; i++)
			{
				int v = -a[i][yy];
				sumx[i] += v - a[i][yy];
				a[i][yy] = v;
				sumy[yy] += v;
			}
		}
		xx = ckx(), yy = cky();
	}
	for (int i = 1; i <= n; totx += (ansx[i] & 1), i++);
	for (int i = 1; i <= m; toty += (ansy[i] & 1), i++);
	printf ("%d ", totx);
	for (int i = 1; i <= n; i++)
		if (ansx[i] & 1)
			printf ("%d ", i);
	printf ("\n%d ", toty);
	for (int i = 1; i <= m; i++)
		if (ansy[i] & 1)
			printf ("%d ", i);
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>
void rd(T &x)
{
	int f = 1;
    x = 0;
    char c;
    while (c = getchar(), c < 48) if (c == '-') f = -1;
    do
    	x = (x << 3) + (x << 1) + (c ^ 48);
    while (c = getchar(), c > 47 && c < 58);
	x *= f;
}
const int N = 105;
int n, m, a[N][N], sumx[N], sumy[N], ansx[N], ansy[N], totx, toty;
int ckx()
{
	for (int i = 1; i <= n; i++)
		if (sumx[i] < 0)
			return i;
	return 0;
}
int cky()
{
	for (int i = 1; i <= m; i++)
		if (sumy[i] < 0)
			return i;
	return 0;
}
int main()
{
	rd(n), rd(m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			rd(a[i][j]), sumx[i] += a[i][j], sumy[j] += a[i][j];
	int xx = ckx(), yy = cky();
	while (xx || yy)
	{
		if (xx)
		{
			++ansx[xx];
			sumx[xx] = 0;
			for (int i = 1; i <= m; i++)
			{
				int v = -a[xx][i];
				sumy[i] += v - a[xx][i];
				a[xx][i] = v;
				sumx[xx] += v;
			}
		}
		if (yy)
		{
			++ansy[yy];
			sumy[yy] = 0;
			for (int i = 1; i <= n; i++)
			{
				int v = -a[i][yy];
				sumx[i] += v - a[i][yy];
				a[i][yy] = v;
				sumy[yy] += v;
			}
		}
		xx = ckx(), yy = cky();
	}
	for (int i = 1; i <= n; totx += (ansx[i] & 1), i++);
	for (int i = 1; i <= m; toty += (ansy[i] & 1), i++);
	cout << totx << ' ';
	for (int i = 1; i <= n; i++)
		if (ansx[i] & 1)
			cout << i << ' ';
	cout << endl << toty << ' ';
	for (int i = 1; i <= m; i++)
		if (ansy[i] & 1)
			cout << i << ' ';
	return 0;
}


#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
template<class T>
void rd(T &x)
{
	int f = 1;
    x = 0;
    char c;
    while (c = getchar(), c < 48) if (c == '-') f = -1;
    do
    	x = (x << 3) + (x << 1) + (c ^ 48);
    while (c = getchar(), c > 47 && c < 58);
	x *= f;
}
const int N = 105;
int n, m, a[N][N], sumx[N], sumy[N], ansx[N], ansy[N], totx, toty;
int ckx()
{
	for (int i = 1; i <= n; i++)
		if (sumx[i] < 0)
			return i;
	return 0;
}
int cky()
{
	for (int i = 1; i <= m; i++)
		if (sumy[i] < 0)
			return i;
	return 0;
}
int main()
{
	rd(n), rd(m);
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			rd(a[i][j]), sumx[i] += a[i][j], sumy[j] += a[i][j];
	int xx = ckx(), yy = cky();
	while (xx || yy)
	{
		if (xx)
		{
			++ansx[xx];
			sumx[xx] = 0;
			for (int i = 1; i <= m; i++)
			{
				int v = -a[xx][i];
				sumy[i] += v - a[xx][i];
				a[xx][i] = v;
				sumx[xx] += v;
			}
		}
		yy = cky();
		if (yy)
		{
			++ansy[yy];
			sumy[yy] = 0;
			for (int i = 1; i <= n; i++)
			{
				int v = -a[i][yy];
				sumx[i] += v - a[i][yy];
				a[i][yy] = v;
				sumy[yy] += v;
			}
		}
		xx = ckx();
	}
	for (int i = 1; i <= n; totx += (ansx[i] & 1), i++);
	for (int i = 1; i <= m; toty += (ansy[i] & 1), i++);
	printf ("%d ", totx);
	for (int i = 1; i <= n; i++)
		if (ansx[i] & 1)
			printf ("%d ", i);
	printf ("\n%d ", toty);
	for (int i = 1; i <= m; i++)
		if (ansy[i] & 1)
			printf ("%d ", i);
	return 0;
}


#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T>
inline int read(T &a) {
    a = 0; char c = getchar(), f = 1;
    while(c > '9' || c < '0') {
        if(c == '-') f = (~f) + 1;
        if(c == -1) return -1;
        c = getchar();
    }
    while(c <= '9' && c >= '0') a = (a << 1) + (a << 3) + (c ^ 48), c = getchar();
    a *= f; return 1;
}
template <typename T>
inline int write(T a) {
    if(a < 0) putchar('-'), a = (~a) + 1;
    if(a / 10) return write(a / 10) & putchar(a % 10 | 48);
    return putchar(a | 48);
}
template <typename T>
inline int write(T a, char c) { return write(a) + putchar(c); }

int n, m;
int a[101][101];
bool row[101], col[101];
int cr, cc;
inline void print() {
    for(int i = 1; i <= n; i++)
        cr += row[i];
    for(int i = 1; i <= m; i++)
        cc += col[i];
    write(cr);
    for(int i = 1; i <= n; i++)
        if(row[i]) putchar(' '), write(i);
    putchar(10);
    write(cc);
    for(int i = 1; i <= m; i++)
        if(col[i]) putchar(' '), write(i);
    putchar(10);
}
inline pair<int, int> check() {
    for(int i = 1; i <= n; i++) {
        int sum = 0;
        for(int j = 1; j <= m; j++)
            sum += a[i][j];
        if(sum < 0) return make_pair(1, i);
    }
    for(int i = 1; i <= m; i++) {
        int sum = 0;
        for(int j = 1; j <= n; j++)
            sum += a[j][i];
        if(sum < 0) return make_pair(2, i);
    }
    print();
    exit(0);
    return make_pair(0, 0);
}
inline int rev(pair<int, int> p) {
    if(p.first == 0) return 0;
    if(p.first == 1) {
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            for(int j = 1; j <= m; j++)
                sum += a[i][j];
            if(sum <= 0) {
                for(int j = 1; j <= m; j++)
                    a[i][j] = (~a[i][j]) + 1;
                row[i] ^= 1;
            }
        }
    }
    else {
        for(int i = 1; i <= m; i++) {
            int sum = 0;
            for(int j = 1; j <= n; j++)
                sum += a[j][i];
            if(sum <= 0) {
                for(int j = 1; j <= m; j++)
                    a[j][i] = (~a[j][i]) + 1;
                col[i] ^= 1;
            }
        }
    }
    return 1;
}
int main() {
    read(n), read(m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            read(a[i][j]);
    while(rev(check())) ;
}


#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T>
inline int read(T &a) {
    a = 0; char c = getchar(), f = 1;
    while(c > '9' || c < '0') {
        if(c == '-') f = (~f) + 1;
        if(c == -1) return -1;
        c = getchar();
    }
    while(c <= '9' && c >= '0') a = (a << 1) + (a << 3) + (c ^ 48), c = getchar();
    a *= f; return 1;
}
template <typename T>
inline int write(T a) {
    if(a < 0) putchar('-'), a = (~a) + 1;
    if(a / 10) return write(a / 10) & putchar(a % 10 | 48);
    return putchar(a | 48);
}
template <typename T>
inline int write(T a, char c) { return write(a) + putchar(c); }

int n, m;
int a[101][101];
bool row[101], col[101];
int cr, cc;
inline void print() {
    for(int i = 1; i <= n; i++)
        cr += row[i];
    for(int i = 1; i <= m; i++)
        cc += col[i];
    write(cr);
    for(int i = 1; i <= n; i++)
        if(row[i]) putchar(' '), write(i);
    putchar(10);
    write(cc);
    for(int i = 1; i <= m; i++)
        if(col[i]) putchar(' '), write(i);
    putchar(10);
}
inline pair<int, int> check() {
    for(int i = 1; i <= n; i++) {
        int sum = 0;
        for(int j = 1; j <= m; j++)
            sum += a[i][j];
        if(sum < 0) return make_pair(1, i);
    }
    for(int i = 1; i <= m; i++) {
        int sum = 0;
        for(int j = 1; j <= n; j++)
            sum += a[j][i];
        if(sum < 0) return make_pair(2, i);
    }
    print();
    exit(0);
    return make_pair(0, 0);
}
inline int rev(pair<int, int> p) {
    if(p.first == 1) {
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            for(int j = 1; j <= m; j++)
                sum += a[i][j];
            if(sum < 0) {
                for(int j = 1; j <= m; j++)
                    a[i][j] = (~a[i][j]) + 1;
                row[i] ^= 1;
            }
        }
    }
    else {
        for(int i = 1; i <= m; i++) {
            int sum = 0;
            for(int j = 1; j <= n; j++)
                sum += a[j][i];
            if(sum < 0) {
                for(int j = 1; j <= m; j++)
                    a[j][i] = (~a[j][i]) + 1;
                col[i] ^= 1;
            }
        }
    }
    return 1;
}
int main() {
    read(n), read(m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            read(a[i][j]);
    while(rev(check())) ;
}


#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T>
inline int read(T &a) {
    a = 0; char c = getchar(), f = 1;
    while(c > '9' || c < '0') {
        if(c == '-') f = (~f) + 1;
        if(c == -1) return -1;
        c = getchar();
    }
    while(c <= '9' && c >= '0') a = (a << 1) + (a << 3) + (c ^ 48), c = getchar();
    a *= f; return 1;
}
template <typename T>
inline int write(T a) {
    if(a < 0) putchar('-'), a = (~a) + 1;
    if(a / 10) return write(a / 10) & putchar(a % 10 | 48);
    return putchar(a | 48);
}
template <typename T>
inline int write(T a, char c) { return write(a) + putchar(c); }

int n, m;
int a[101][101];
bool row[101], col[101];
int cr, cc;
inline void print() {
    for(int i = 1; i <= n; i++)
        cr += row[i];
    for(int i = 1; i <= m; i++)
        cc += col[i];
    write(cr);
    for(int i = 1; i <= n; i++)
        if(row[i]) putchar(' '), write(i);
    putchar(10);
    write(cc);
    for(int i = 1; i <= m; i++)
        if(col[i]) putchar(' '), write(i);
    putchar(10);
}
inline pair<int, int> check() {
    for(int i = 1; i <= n; i++) {
        int sum = 0;
        for(int j = 1; j <= m; j++)
            sum += a[i][j];
        if(sum < 0) return make_pair(1, i);
    }
    for(int i = 1; i <= m; i++) {
        int sum = 0;
        for(int j = 1; j <= n; j++)
            sum += a[j][i];
        if(sum < 0) return make_pair(2, i);
    }
    print();
    exit(0);
    return make_pair(0, 0);
}
inline int rev(pair<int, int> p) {
    if(p.first == 0) return 0;
    if(p.first == 1) {
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            for(int j = 1; j <= m; j++)
                sum += a[i][j];
            if(sum <= 0) {
                for(int j = 1; j <= m; j++)
                    a[i][j] = (~a[i][j]) + 1;
                row[i] ^= 1;
            }
        }
    }
    else {
        for(int i = 1; i <= m; i++) {
            int sum = 0;
            for(int j = 1; j <= n; j++)
                sum += a[j][i];
            if(sum <= 0) {
                for(int j = 1; j <= n; j++)
                    a[j][i] = (~a[j][i]) + 1;
                col[i] ^= 1;
            }
        }
    }
    return 1;
}
int main() {
    read(n), read(m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            read(a[i][j]);
    while(rev(check())) ;
}


#include <map>
#include <cmath>
#include <queue>
#include <vector>
#include <cstdio>
#include <cctype>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T>
inline int read(T &a) {
    a = 0; char c = getchar(), f = 1;
    while(c > '9' || c < '0') {
        if(c == '-') f = (~f) + 1;
        if(c == -1) return -1;
        c = getchar();
    }
    while(c <= '9' && c >= '0') a = (a << 1) + (a << 3) + (c ^ 48), c = getchar();
    a *= f; return 1;
}
template <typename T>
inline int write(T a) {
    if(a < 0) putchar('-'), a = (~a) + 1;
    if(a / 10) return write(a / 10) & putchar(a % 10 | 48);
    return putchar(a | 48);
}
template <typename T>
inline int write(T a, char c) { return write(a) + putchar(c); }

int n, m;
int a[101][101];
bool row[101], col[101];
int cr, cc;
inline void print() {
    for(int i = 1; i <= n; i++)
        cr += row[i];
    for(int i = 1; i <= m; i++)
        cc += col[i];
    write(cr);
    for(int i = 1; i <= n; i++)
        if(row[i]) putchar(' '), write(i);
    putchar(10);
    write(cc);
    for(int i = 1; i <= m; i++)
        if(col[i]) putchar(' '), write(i);
    putchar(10);
}
inline pair<int, int> check() {
    for(int i = 1; i <= n; i++) {
        int sum = 0;
        for(int j = 1; j <= m; j++)
            sum += a[i][j];
        if(sum < 0) return make_pair(1, i);
    }
    for(int i = 1; i <= m; i++) {
        int sum = 0;
        for(int j = 1; j <= n; j++)
            sum += a[j][i];
        if(sum < 0) return make_pair(2, i);
    }
    print();
    exit(0);
    return make_pair(0, 0);
}
inline int rev(pair<int, int> p) {
    if(p.first == 1) {
        for(int i = 1; i <= n; i++) {
            int sum = 0;
            for(int j = 1; j <= m; j++)
                sum += a[i][j];
            if(sum <= 0) {
                for(int j = 1; j <= m; j++)
                    a[i][j] = (~a[i][j]) + 1;
                row[i] ^= 1;
            }
        }
    }
    else {
        for(int i = 1; i <= m; i++) {
            int sum = 0;
            for(int j = 1; j <= n; j++)
                sum += a[j][i];
            if(sum <= 0) {
                for(int j = 1; j <= m; j++)
                    a[j][i] = (~a[j][i]) + 1;
                col[i] ^= 1;
            }
        }
    }
    return 1;
}
int main() {
    read(n), read(m);
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            read(a[i][j]);
    while(rev(check())) ;
}


#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int sum=0,ff=1; char ch=getchar();
	while(!isdigit(ch))
	{
		if(ch=='-') ff=-1;
		ch=getchar();
	}
	while(isdigit(ch))
		sum=sum*10+(ch^48),ch=getchar();
	return sum*ff;
}
int mp[105][105] , n , m , ans1[105] , ans2[105] , tot1 , tot2 , ji1[105] , ji2[105];
bool cheak() {
	for(int i = 1 ; i <= n ; i ++) {
		int x = 0;
		for(int j = 1 ; j <= m ; j ++)
			x += mp[i][j];
		if(x < 0) return 1;
	}
	for(int i = 1 ; i <= m ; i ++) {
		int x = 0;
		for(int j = 1 ; j <= n ; j ++)
			x += mp[j][i];
		if(x < 0) return 1;
	}
	return 0;
}
main() {
	n = read() , m = read();
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= m ; j ++)
			mp[i][j] = read();
	while(cheak()) {
		for(int i = 1 ; i <= n ; i ++) {
		int x = 0;
		for(int j = 1 ; j <= m ; j ++)
			x += mp[i][j];
		if(x < 0){
			ji1[i]++;
			for(int j = 1 ; j <= m ; j ++)
				mp[i][j] = -mp[i][j];
		}
	}
	for(int i = 1 ; i <= m ; i ++) {
		int x = 0;
		for(int j = 1 ; j <= n ; j ++)
			x += mp[j][i];
		if(x < 0) {
			ji2[i]++;
			for(int j = 1 ; j <= n ; j ++)
				mp[j][i] = -mp[j][i];
		}
	}
	}
	for(int i = 1 ; i <= n ; i ++)
		if(ji1[i]&1) ans1[++tot1] = i;
	for(int i = 1 ; i <= m ; i ++)
		if(ji2[i]&1) ans2[++tot2] = i;
	cout<<tot1<<" ";
	for(int i = 1 ; i <= tot1 ; i ++) cout << ans1[i]<<" ";
	cout<<endl;
	cout<<tot2<<" ";
	for(int i = 1 ; i <= tot2 ; i ++) cout << ans2[i]<<" ";
}


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
inline void re(int &x)
{
	x=0;bool flag=false;
	char c=getchar();
	while(c<'0'||c>'9'){
		flag= c=='-';
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+(c^'0');
		c=getchar();
	}
	if(flag)x=-x;
	return ;
}
int a[110][110];
int Sr[110],Sc[110];
int revr[110],revc[110];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			scanf("%d",&a[i][j]);
			Sr[i]+=a[i][j];
			Sc[j]+=a[i][j];
		}
	while(1)
	{
		bool flag=false;
		for(int i=1;i<=n;i++)
			if(Sr[i]<0)flag=true;
		for(int i=1;i<=m;i++)
			if(Sc[i]<0)flag=true;
		if(!flag)break;
		for(int i=1;i<=n;i++)
			if(Sr[i]<0)
			{
				Sr[i]=-Sr[i];
				revr[i]^=1;
				for(int j=1;j<=m;j++)
				{
					Sc[j]-=2*a[i][j];
					a[i][j]*=-1;
				}
			}
		for(int j=1;j<=m;j++)
			if(Sc[j]<0)
			{
				Sc[j]=-Sc[j];
				revc[j]^=1;
				for(int i=1;i<=n;i++)
				{
					Sr[i]-=2*a[i][j];
					a[i][j]*=-1;
				}
			}
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
		cnt+=revr[i];
	printf("%d ",cnt);
	for(int i=1;i<=n;i++)
		if(revr[i])printf("%d ",i);
	cnt=0;
	for(int i=1;i<=m;i++)
		cnt+=revc[i];
	printf("\n%d ",cnt);
	for(int i=1;i<=m;i++)
		if(revc[i])printf("%d ",i);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int n;
int m;
int a[123][123];
int row[123];
int col[123];

bool go() {
  for (int i = 0; i < n; ++i) {
    int sum = 0;
    for (int j = 0; j < m; ++j) {
      sum += a[i][j];
    }
    if (sum < 0) {
      for (int j = 0; j < m; ++j) {
        a[i][j] = -a[i][j];
      }
      row[i] = 1 - row[i];
      return true;
    }
  }
  for (int j = 0; j < m; ++j) {
    int sum = 0;
    for (int i = 0; i < n; ++i) {
      sum += a[i][j];
    }
    if (sum < 0) {
      for (int i = 0; i < n; ++i) {
        a[i][j] = -a[i][j];
      }
      col[j] = 1 - col[j];
      return true;
    }
  }
  return false;
}

int main() {
  // freopen("in", "r", stdin); freopen("out", "w", stdout);
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", a[i] + j);
    }
  }
  memset(row, 0, sizeof row);
  memset(col, 0, sizeof col);
  while (go());
  int size_r = 0, size_c = 0;
  for (int i = 0; i < n || i < m; ++i) {
    if (i < n) {
      size_r += row[i];
    }
    if (i < m) {
      size_c += col[i];
    }
  }
  printf("%d ", size_r);
  for (int i = 0; i < n; ++i) {
    if (row[i] == 1) {
      printf("%d ", i + 1);
    }
  }
  printf("\n");
  printf("%d ", size_c);
  for (int i = 0; i < m; ++i) {
    if (col[i] == 1) {
      printf("%d ", i + 1);
    }
  }
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

int a[123456];
long long sum[123456];

int main() {
  // freopen("in", "r", stdin); freopen("out", "w", stdout);
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  reverse(a, a + n);
  sum[0] = 0;
  for (int i = 0; i < n; ++i) {
    sum[i + 1] = sum[i] + a[i];
  }
  long long ans1 = 0;
  for (int i = 0; i < n; ++i) {
    ans1 += 1LL * i * a[i];
  }
  int qq;
  scanf("%d", &qq);
  while (qq--) {
    int k;
    scanf("%d", &k);
    if (k == 1) {
      cout << ans1 << '\n';
    } else {
      long long ans = 0;
      long long pot = 1, pos = 1;
      int it = 0;
      while (pos - pot < n) {
        ans += it * (sum[min(0LL + n, pos)] - sum[pos - pot]);
        pot *= k;
        pos += pot;
        ++it;
      }
      cout << ans << '\n';
    }
  }
  return 0;
}


n=int(input())
l=[]
for i in range(0,n):
    l.append(int(input()))
l.sort()
i=n-1
ans=n
j=n//2-1
while(j>=0 and i>=n//2):
    if((l[j]*2)<=l[i]):
        i-=1
        ans-=1
    j-=1
print(ans)


n=int(input())
k=[]
for i in range(n):
    k.append(int(input()))
k.sort()
if(n==1):
    print(1)
else:
    j=n-1
    i=n-2
    c=0
    visited=[True for i in range(n)]
    while(i>=0):
        if(visited[i]==False):
            i-=1
        elif(visited[j]==False):
            j-=1
        else:
            if(2*k[i]<=k[j]):
                visited[i]=False
                visited[j]=False
                i-=1
                j-=1
                n-=1
            else:
                i-=1
    print(n)


import sys
input = sys.stdin.buffer.readline
n=int(input())
l=[]
for i in range(0,n):
    l.append(int(input()))
l.sort()
i=n-1
ans=n
j=n//2-1
while(j>=0 and i>=n//2):
    if((l[j]*2)<=l[i]):
        i-=1
        ans-=1
    j-=1
print(ans)


n=int(input())
k=[]
for i in range(n):
    k.append(int(input()))
k.sort()
def bs(start,end,x):
    while(start<=end):
        mid=start+(end-start)//2
        if(k[mid]>=2*x):
            return 1
        else:
            start=mid+1
    return 0

for i in range(n):
    if(bs(i+1,n-1,k[i])):
        continue
    else:
        d=i
        break
print(n-d)


n=int(input())
k=[]
for i in range(n):
    k.append(int(input()))
k.sort()
if(n==1):
    print(1)
else:
    j=n-1
    i=n-2
    c=0
    visited=[True for i in range(n)]
    while(i>=0):
        if(visited[i]==False):
            i-=1
        elif(visited[j]==False):
            j-=1
        else:
            if(2*k[i]<=k[j]):
                visited[i]=False
                visited[j]=False
                c+=1
                i-=1
                j-=1
            else:
                i-=1

    print(n-c+1)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

import time
start_time = time.time()

import collections as col
import math, string
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
Greedily take the smallest kangaroo and put it in the pouch of the smallest kangaroo that can hold it
"""

def solve():
    N = getInt()
    A = []
    used = set()
    carriers = set()
    for n in range(N):
        A.append(getInt())
    A.sort()
    #print(A)
    i = N-1
    j = N-1
    ans = N
    while i > -1:
        j = min(i,j)
        if i in used:
            i -= 1
            continue
        while j > -1 and (A[i] < 2*A[j] or j in used):
            j -= 1
        if j == -1:
            #print(carriers)
            #print(used)
            return ans
        assert(j<i)
        used.add(j)
        carriers.add(i)
        i -= 1
        j -= 1
        ans -= 1
    #print(used,carriers)
    return ans

#for _ in range(getInt()):
print(solve())


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

import time
start_time = time.time()

import collections as col
import math, string
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
Greedily take the smallest kangaroo and put it in the pouch of the smallest kangaroo that can hold it
"""

def solve():
    N = getInt()
    A = []
    used = set()
    carriers = col.defaultdict(int)
    for n in range(N):
        A.append(getInt())
    A.sort()
    i = N-1
    j = N-1
    ans = N
    while i > -1:
        j = min(i,j,N//2-1)
        if i in used:
            i -= 1
            continue
        while j > -1 and (A[i] < 2*A[j] or j in used):
            j -= 1
        if j == -1:
            return ans
        assert(j<i)
        used.add(j)
        carriers[A[i]] = A[j]
        i -= 1
        ans -= 1
    return ans

#for _ in range(getInt()):
print(solve())


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

import time
start_time = time.time()

import collections as col
import math, string
from functools import reduce

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
Greedily take the smallest kangaroo and put it in the pouch of the smallest kangaroo that can hold it
"""

def solve():
    N = getInt()
    A = []
    used = set()
    carriers = set()
    for n in range(N):
        A.append(getInt())
    A.sort()
    #print(A)
    i = N-1
    j = N-1
    ans = N
    while i > -1:
        j = min(i,j)
        if i in used:
            i -= 1
            continue
        while j > -1 and (A[i] < 2*A[j] or j in used):
            j -= 1
        if j == -1:
            #print(carriers)
            #print(used)
            return ans
        assert(j<i)
        used.add(j)
        carriers.add(i)
        i -= 1
        ans -= 1
    #print(used,carriers)
    return ans

#for _ in range(getInt()):
print(solve())


n=int(input())

s=[0 for i in range(0,n)]
for i in range(0,n):
    s[i]=int(input())

s.sort()

p=n//2+n%2

visible=n

for i in range(0,n//2):

    if p<n and s[p]<2*s[i]:

        beg=p
        end=n

        while beg<end:
            p=(beg+end)//2

            if s[p]>=2*s[i] and s[p-1]<2*s[i]:
                break
            elif s[p]>=2*s[i]:
                end=p
            elif s[p]<2*s[i]:
                beg=p+1
        if beg==end:
            p=n
    if p==n:
        break
    visible=visible-1
    p+=1

print (visible)


n=int(input())

s=[0 for i in range(0,n)]
for i in range(0,n):
    s[i]=int(input())

s.sort()

p=n//2+n%2

visible=n

for i in range(0,n//2):
    while p<n and s[p]<2*s[i]:
        p+=1
    if p==n:
        break
    visible=visible-1
    p+=1

print (visible)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

n=int(input())

s=[0 for i in range(0,n)]
for i in range(0,n):
    s[i]=int(input())

s.sort()
# print (s)

p=n//2+n%2

visible=n
y=0
for i in range(p,p+n//2):
    if s[y]*2<=s[i]:
        visible-=1
        y+=1

print (visible)


n = int(input())
a = list(sorted([int(input()) for _ in range(n)]))

i, j = 0, n // 2
cnt = 0
while j < n:
    if a[i] == -1:
        i += 1
        if i == j:
            j += 1
        continue
    if a[i] * 2 <= a[j]:
        cnt += 1
        a[j] = -1
        i += 1
    j += 1

print(n - cnt)


n = int(input())
a = list(sorted([int(input()) for _ in range(n)]))

i, j = 0, n // 2
cnt = 0
while j < n:
    if a[i] == -1:
        i += 1
        if i == j:
            j += 1
    elif a[i] * 2 <= a[j]:
        cnt += 1
        a[j] = -1
        i += 1
    j += 1

print(n - cnt)


import sys

n = int(input())
a = list(sorted([int(next(sys.stdin)) for _ in range(n)]))

i, j = 0, n // 2
cnt = 0
while j < n:
    if a[i] == -1:
        i += 1
        if i == j:
            j += 1
    elif a[i] * 2 <= a[j]:
        cnt += 1
        a[j] = -1
        i += 1
    j += 1

print(n - cnt)


from bisect import bisect_left

def ans(a,n):
    i = 0
    ret = n
    while True:
        pos = bisect_left(a,a[i]*2)
        if pos < n:
            ret-=1
        else:
            break
        i+=1
    return ret

n = int(input())
a = [None]*n
for _ in range(n):
    a[_] = int(input())
a.sort()
print(ans(a,n))


from bisect import bisect_right

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
ans = n
it = n-1
left = 0
right = n-1
while left <= right:
    x = a[it]//2
    pos = bisect_right(a,x,left,right)
    if pos > right or a[pos] > x:
        pos-=1
    right = pos-1
    ans-=1
    it-=1

print(ans)


n = int(input())
a = [None]*n
for i in range(n):
    a[i] = int(input())
a.sort()
i = 0
j = n//2
ans=n
while i < n//2 and j < n:
    if 2*a[i] <= a[j]:
        ans-=1
        i+=1
        j+=1
    else:
        j+=1
print(ans)


from bisect import bisect_left

def ans(a,n):
    i = 0
    ret = n
    low = n//2
    while True:
        pos = bisect_left(a,a[i]*2,low,n)
        if pos < n:
            ret-=1
            low = pos+1
        else:
            break
        i+=1
    return ret

n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
a.sort()
print(ans(a,n))


import sys
import math
n = int(input())
k = [int(x) for x in sys.stdin]
size = (5*10**5+4)
r = [0]*size
c = [0]*size
for i in k:
    r[i//2]+=1 #neu co so = x2 -> +1
    c[i]+=1 #dem so lan xuat hien trong input
t = b = 0
result = n
for i in range(size-1, -1, -1):
    r[i]+=t
    t=r[i]
    if (c[i]>0):
        result-=min(c[i], r[i]-b)
        b+=min(c[i], r[i]-b)
    if (result<=((n+1)//2)):
        break
print(max(result,(n+1)//2))


from bisect import bisect_left

def ans(a,n):
    i = 0
    ret = n
    low = n//2
    while True:

        pos = bisect_left(a,a[i]*2,low,n)
        if pos < n:
            ret-=1
            low = pos+1
        else:
            break
        i+=1
    return ret

n = int(input())
a = [None]*n
for _ in range(n):
    a[_] = int(input())
a.sort()
print(ans(a,n))


import sys

def ans(a,n):
    i = 0
    j = n//2
    ret = n
    while j < n:
        if 2*a[i] <= a[j]:
            i+= 1
            j+=1
            ret -= 1
        else:
            j+=1
    return ret

n = int(input())
a = [int(i) for i in sys.stdin]

a.sort()
print(ans(a,n))


import sys
from bisect import bisect_left

def ans(a,n):
    i = 0
    ret = n
    low = n//2
    while True:
        pos = bisect_left(a,a[i]*2,low,n)
        if pos < n:
            ret-=1
            low = pos+1
        else:
            break
        i+=1
    return ret

n = int(input())
a = [int(i) for i in sys.stdin]

a.sort()
print(ans(a,n))


import sys

def sol(a,n):
    a.sort()
    i = 0
    j = n//2
    ans = n
    while i < n//2 and j < n:
        if 2*a[i] <= a[j]:
            ans-=1
            i+=1
            j+=1
        else:
            j+=1
    return ans

n = int(input())
a = [int(i) for i in sys.stdin]
print(sol(a,n))


import sys

n = int(input())
a = [int(i) for i in sys.stdin]
a.sort()
i = 0
j = n//2
ans=n
while i < n//2 and j < n:
    if 2*a[i] <= a[j]:
        ans-=1
        i+=1
        j+=1
    else:
        j+=1
print(ans)


n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
i = 0
j = n//2
ans=n
while i < n//2 and j < n:
    if 2*a[i] <= a[j]:
        ans-=1
        i+=1
        j+=1
    else:
        j+=1
print(ans)


from bisect import bisect_left

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
ans = n
it = n-1
left = 0
right = n-1
while left <= right:
    x = a[it]//2
    pos = bisect_left(a,x,left,right)
    if pos > right or a[pos] > x:
        pos-=1
    right = pos-1
    ans-=1
    it-=1

print(ans)


import sys

def ans(a,n):
    i = 0
    j = n//2
    ret = n
    while i < n//2 and j < n:
        if 2*a[i] <= a[j]:
            i+= 1
            j+=1
            ret -= 1
        else:
            j+=1
    return ret

n = int(input())
a = [int(i) for i in sys.stdin]

a.sort()
print(ans(a,n))


from bisect import bisect_right

n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
a.sort()
ans = n
it = n-1
left = 0
right = n-1
while left <= right:
    x = a[it]//2
    pos = bisect_right(a,x,left,right)
    if pos > right or a[pos] > x:
        pos-=1
    right = pos-1
    if pos < 0:
        break
    ans-=1
    it-=1

print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
def prime_factors(x):
    s=set()
    n=x
    i=2
    while i*i<=n:
        if n%i==0:
            while n%i==0:
                n//=i
            s.add(i)
        i+=1
    if n>1:
        s.add(n)
    return s
from collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
# n = int(input())
# ls = list(map(int, input().split()))
# n, k = map(int, input().split())
# n =int(input())
#arr=[(i,x) for i,x in enum]
#arr.sort(key=lambda x:x[0])
#print(arr)
#import math
# e=list(map(int, input().split()))
from collections import Counter
#print("\n".join(ls))
#print(os.path.commonprefix(ls[0:2]))
#n=int(input())
from bisect import  bisect_right
#d=sorted(d,key=lambda x:(len(d[x]),-x))  d=dictionary     d={x:set() for x in arr}
#n=int(input())
#n,m,k= map(int, input().split())
import heapq
#for _ in range(int(input())):
#n,k=map(int, input().split())
#input=sys.stdin.buffer.readline
#for _ in range(int(input())):
n=int(input())
    #n, k = map(int, input().split())

    #arr = list(map(int, input().split()))
import bisect
def can(x):
    a=arr[:x]

    cnt=0
    for i in range(x-1,-1,-1):
        var=n-bisect.bisect_left(arr,2*a[i])
        var-=cnt
        if var>=1:
            pass
        else:
            return False
        cnt+=1
    return True

arr=[]
for i in range(n):
    m=int(input())
    arr.append(m)
arr.sort()
l=0
r=n//2
ans=-1
while l<=r:
    mid=(l+r)//2
    if can(mid):

        ans=mid
        l=mid+1
    else:
        r=mid-1
print(n-ans)


for i in range(n):
    m=int(input())
    arr.append(m)
arr.sort()
l=n//2 - 1
r=n-1
ans=0
while l>=0 and r>n//2-1:
    if arr[l]*2<=arr[r]:
        r-=1
        ans+=1

    l-=1
print(n-ans)


from sys import stdin
n = int(stdin.readline())
l = [int(line) for line in stdin.readlines()]
l.sort(reverse=True)
ptr = n // 2
ans = n
for i in range(n // 2):
	while ptr < n and l[ptr] * 2 > l[i]:
		ptr += 1
	if ptr < n and l[ptr] * 2 <= l[i]:
		ans -= 1
	ptr += 1
print(ans)


n = int(input())
l = []
for i in range(n):
	l.append(int(input()))
l.sort(reverse=True)
ptr = n // 2
ans = n
for i in range(n // 2):
	while ptr < n and l[ptr] * 2 > l[i]:
		ptr += 1
	if ptr < n and l[ptr] * 2 <= l[i]:
		ans -= 1
	ptr += 1
print(ans)


import sys
import math
n=int(input())
a=sorted(int(x) for x in sys.stdin)
i=(n//2)-1
j=n-1
k=0
while j>((n//2)-1) and i>=0:
    b = int(2*a[i]<=a[j])
    j-=1*b
    k+=1*b
    i-=1
#print(a)
print(n-k)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
from bisect import  bisect_left
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
l.sort()
ans=n
for i in range(n//2):
    a=bisect_left(l,2*l[i])
    if a<n:
        ans-=1
print(ans)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
###################################################
from bisect import  bisect_left
n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
l.sort()
ans=n
x=0
for i in range(n//2):
    a=bisect_left(l,2*l[i])
    if a<n:
        if a>x:
            x=a+1
        else:
            x+=1
        if x<=n:
            ans-=1
print(ans)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
n=int(input())
l=[]
from bisect import bisect
for i in range(n):
    l.append(int(input()))
l.sort()
while 1:
    b=l[-1]//2
    a=bisect(l,b)
    if a!=0:
        l.pop(a-1)
        l.pop(-1)
        n-=1
    else:
        break
print(n)


import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
n=int(input())
l=[]
from bisect import bisect
for i in range(n):
    l.append(int(input()))
l.sort()
while 1:
    if len(l)==0:
        break
    b=l[-1]//2
    a=bisect(l,b)
    if a!=0:
        l.pop(a-1)
        l.pop(-1)
        n-=1
    else:
        break
print(n)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *

getcontext().prec = 25

MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def binary_search(data, val, le):
    test = le
    if val >= data[-1]:
        return [test - 1, test - 1]
    elif val <= data[0]:
        return [0, 0]
    high_index = test - 1
    low_index = 0
    while high_index > low_index:
        index = (high_index + low_index) // 2
        sub = data[index]
        if data[low_index] == val:
            return [low_index, low_index]
        elif sub == val:
            return [index, index]
        elif data[high_index] == val:
            return [high_index, high_index]
        elif sub > val:
            if high_index == index:
                return sorted([high_index, low_index])
            high_index = index
        else:
            if low_index == index:
                return sorted([high_index, low_index])
            low_index = index
    return sorted([high_index, low_index])

# n, k = map(int, input().split(" "))
# l = list(map(int, input().split(" ")))

n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
a = l[-1] // 2
x = binary_search(l, a, n)[0]
while l[x] <= a:
    x += 1
if x > n // 2:
    x = n//2
i = 0
c = 0
while l[i] <= a and x < n:
    if l[i] <= l[x] // 2:
        c += 1
        i += 1
        x += 1
    else:
        x += 1
# print(*l)
# print(a)

print(n-c)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *

getcontext().prec = 25

MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def binary_search(data, val, le):
    test = le
    if val >= data[-1]:
        return [test - 1, test - 1]
    elif val <= data[0]:
        return [0, 0]
    high_index = test - 1
    low_index = 0
    while high_index > low_index:
        index = (high_index + low_index) // 2
        sub = data[index]
        if data[low_index] == val:
            return [low_index, low_index]
        elif sub == val:
            return [index, index]
        elif data[high_index] == val:
            return [high_index, high_index]
        elif sub > val:
            if high_index == index:
                return sorted([high_index, low_index])
            high_index = index
        else:
            if low_index == index:
                return sorted([high_index, low_index])
            low_index = index
    return sorted([high_index, low_index])

# n, k = map(int, input().split(" "))
# l = list(map(int, input().split(" ")))

n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
a = l[-1] // 2
x = binary_search(l, a, n)[0]
while l[x] <= a:
    x += 1

i = 0
c = 0
while l[i] <= a and x < n:
    if l[i] <= l[x] // 2:
        c += 1
        i += 1
        x += 1
    else:
        x += 1

print(n-c)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *

getcontext().prec = 25

MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def binary_search(data, val, le):
    test = le
    if val >= data[-1]:
        return [test - 1, test - 1]
    elif val <= data[0]:
        return [0, 0]
    high_index = test - 1
    low_index = 0
    while high_index > low_index:
        index = (high_index + low_index) // 2
        sub = data[index]
        if data[low_index] == val:
            return [low_index, low_index]
        elif sub == val:
            return [index, index]
        elif data[high_index] == val:
            return [high_index, high_index]
        elif sub > val:
            if high_index == index:
                return sorted([high_index, low_index])
            high_index = index
        else:
            if low_index == index:
                return sorted([high_index, low_index])
            low_index = index
    return sorted([high_index, low_index])

# n, k = map(int, input().split(" "))
# l = list(map(int, input().split(" ")))

n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
a = l[-1] // 2
x = binary_search(l, a, n)[0]
while l[x] <= a:
    x += 1
if x > n // 2:
    x = n//2 + n%2
i = 0
c = 0
while l[i] <= a and x < n:
    if l[i] <= l[x] // 2:
        c += 1
        i += 1
        x += 1
    else:
        x += 1
# print(*l)
# print(a)

print(n-c)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *

getcontext().prec = 25

MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

def binary_search(data, val, le):
    test = le
    if val >= data[-1]:
        return [test - 1, test - 1]
    elif val <= data[0]:
        return [0, 0]
    high_index = test - 1
    low_index = 0
    while high_index > low_index:
        index = (high_index + low_index) // 2
        sub = data[index]
        if data[low_index] == val:
            return [low_index, low_index]
        elif sub == val:
            return [index, index]
        elif data[high_index] == val:
            return [high_index, high_index]
        elif sub > val:
            if high_index == index:
                return sorted([high_index, low_index])
            high_index = index
        else:
            if low_index == index:
                return sorted([high_index, low_index])
            low_index = index
    return sorted([high_index, low_index])

# n, k = map(int, input().split(" "))
# l = list(map(int, input().split(" ")))

n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
a = l[-1] // 2
x = binary_search(l, a, n)[0]
while l[x] <= a:
    x += 1
if x > n // 2:
    x = n//2 - 1
i = 0
c = 0
while l[i] <= a and x < n:
    if l[i] <= l[x] // 2:
        c += 1
        i += 1
        x += 1
    else:
        x += 1
# print(*l)
# print(a)

print(n-c)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *

getcontext().prec = 25

MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# n, k = map(int, input().split(" "))
# l = list(map(int, input().split(" ")))

n = int(input())
l = [int(input()) for i in range(n)]
l.sort()
a = l[-1] // 2

x = n//2 + n%2
i = 0
c = 0
while l[i] <= a and x < n:
    if l[i] <= l[x] // 2:
        c += 1
        i += 1
        x += 1
    else:
        x += 1
# print(*l)
# print(a)

print(n-c)


import sys

input = lambda: sys.stdin.readline().strip("\r\n")

n = int(input())
s = []
for _ in range(n):
    size = int(input())
    s.append(size)
s.sort()
# print(*s)
mid = n // 2 - 1
l = 0
r = n - 1
while mid > 0:
    if s[mid] * 2 > s[n-1]:
        mid -= 1
        r -= 1
    else:
        break
print(r-1)


import sys

input = lambda: sys.stdin.readline().strip("\r\n")

n = int(input())
s = []
for _ in range(n):
    size = int(input())
    s.append(size)
s.sort()
# print(*s)
mid = n // 2 - 1
l = 0
r = n - 1
while mid >= 0:
    if s[mid] * 2 <= s[r]:
        r -= 1
        l += 1
    mid -= 1
print(n - l)


import sys
input = sys.stdin.readline

n = int(input())
l = []
for _ in range(n):
    x = int(input())
    l.append(x)

cnt = 0
l.sort()
i = 0
j = n//2
#print(l)
while(i < n//2 and j < n):
    if l[i]*2 <= l[j]:
        cnt = cnt+1
        j = j+1
        i = i+1

    else:
        j = j+1

print(cnt+(n-(cnt*2)))


n = int(input())
o = [0]*n
l = []
for _ in range(n):
    x = int(input())
    l.append(x)

l.sort()
j = n-1
i = n-1
cnt = 0
while(j > -1 and i > -1):
    if o[j] == 0:
        y = l[j] // 2
        while (l[i] > y and i > -1):
            i = i - 1

        if l[i] <= y:
            cnt = cnt + 1
            o[j] = 1
            o[i] = 1
            i = i-1

    j = j-1

#print(cnt,"l")
#print(o)
print(o.count(0)+cnt)


n = int(input())
l = []
for _ in range(n):
    x = int(input())
    l.append(x)

cnt = 0
l.sort()
i = 0
j = n//2
#print(l)
while(i < n//2 and j < n):
    if l[i]*2 <= l[j]:
        cnt = cnt+1
        j = j+1
        i = i+1

    else:
        j = j+1

print(cnt+(n-(cnt*2)))


n = int(input())
l = []
for _ in range(n):
    x = int(input())
    l.append(x)

cnt = 0
l.sort()
i = 0
j = (n//2)-1
while(i < (n//2)-1 and j < n):
    if l[i]*2 <= l[j]:
        cnt = cnt+1
        j = j+1
        i = i+1

    else:
        j = j+1

print(cnt+(n-(cnt*2)))


#include <bits/stdc++.h>

#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forn(i, n) fore(i, 0, n)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define for1(i, n) for(int i = 1; i < int(n); ++i)

#define mp make_pair
#define pb push_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

#define correct(x, y, xmax, ymax) ((x) >= 0 && (x) < (xmax) && (y) >= 0 && (y) < (ymax))
//#define max(a, b) ((a > b)? a : b)
//#define min(a, b) ((a < b)? a : b)
//#define abs(a) ((a < 0) ? -a : a)
//#define sqr(a) (a * a)

using namespace std;

template<class T> T gcd(T a, T b) { while(a > 0){ b %= a; swap(a, b);} return b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

template<class A, class B> ostream& operator <<(ostream &out, const pair<A, B> &p) {
    return out << "(" << p.x << ", " << p.y << ")";
};

template<class A> ostream& operator <<(ostream &out, const vector<A> &v) {
    out << "[";
    forn(i, sz(v)) {
        if(i)
            out << ", ";
        out << v[i];
    }
    return out << "]";
}

mt19937 myRand(time(NULL)); // [0, 2^32)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
typedef vector <int> vi;

const int dx[] = {-1, 0, 1,  0};
const int dy[] = { 0, 1, 0, -1};
const int dxK[] = {-1, -1, 0, 1, 1,  1,  0, -1};
const int dyK[] = { 0,  1, 1, 1, 0, -1, -1, -1};
const int dxKn[] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[] = { 1,  2, 2, 1, -1, -2, -2, -1};

const int INF = int(1e9) + 100;
const li INF64 = li(1e18) + 100;
const ld EPS = 1e-9;
const ld PI = acosl(-1.0);
const int N = 100009;

li n;
string s;
string bst[N];
map<li, string> bst2;

string tos(li a){
	if(a == 0) return "0";
	string res = "";
	while(a > 0) res += '0' + (a % 10), a /= 10;
	reverse(all(res));
	return res;
}

void precalc(){
	for(int i = 1; i < N; ++i) bst[i] = tos(i);
	for(int i = 2; i < N; ++i){
		li cur = i * 1LL * i;
		for(int x = 2; cur < N; cur *= i, ++x){
			string ns = tos(i) + "^" + tos(x);
			if(sz(ns) < sz(bst[cur])) bst[cur] = ns;
		}
	}

	for(int i = 2; i < N; ++i){
		for(int j = 2; j * j <= i; ++j){
			if(i % j != 0) continue;
			{
				int c = j;
				int c2 = i / j;
				string ns = bst[c] + "*" + bst[c2];
				if(sz(ns) < sz(bst[i])) bst[i] = ns;
			}
			{
				int c = i / j;
				int c2 = j;
				string ns = bst[c] + "*" + bst[c2];
				if(sz(ns) < sz(bst[i])) bst[i] = ns;
			}
		}
	}
//return;
	for(int i = 2; i < N; ++i){
		li cur = i * 1LL * i;
		for(int x = 2; cur < 20000000000; cur *= i, ++x){
			string ns = tos(i) + "^" + tos(x);
			if(!bst2.count(cur) || sz(bst2[cur]) > sz(ns))
				bst2[cur] = ns;
		}
	}
}

inline bool read() {
    if(!(cin >> s))
    	return false;
    return true;
}

string ans;

inline void solve() {
	//n = atoi(s.c_str());
//	cout << bst2[1953125] << endl;
	li n = 0;
	forn(i, sz(s)) n = 10LL * n + s[i] - '0';
//	cout << n << endl;
	ans = s;
	for(li a = 2; a <= N; ++a){
		li cur = a * a;

		for(li b = 2; cur <= n; ++b, cur *= a){

			for(li c = 2; c < 400; ++c){
				li p = c * cur;
				li rem = n - p;
				if(rem < 0) break;
				string ns = tos(c) + "*" + tos(a) + "^" + tos(b);
				if(rem >= N) {
//					continue;
					if(bst2.count(rem)){
						string ns2 = ns + "+" + bst2[rem];
						if(sz(ans) > sz(ns2)) ans = ns2;
					}
					continue;
				}

				if(rem > 0){
					ns += "+" + bst[rem];
				}

				if(sz(ans) > sz(ns)) ans = ns;
			}

			if(n % cur == 0){

				li rem = n / cur;
				string ns = tos(a) + "^" + tos(b) + "*";
				string add = tos(rem);
				if(bst2.count(rem) && sz(bst2[rem]) < sz(add))
					add = bst2[rem];
				if(rem < N && sz(bst[rem]) < sz(add))
					add = bst[rem];
				ns += add;//if(cur == 59049) cout << ns << endl;
				if(sz(ans) > sz(ns)) ans = ns;
			}

			{
				li p = cur;
				li rem = n - p;
				if(rem < 0) break;
				string ns = tos(a) + "^" + tos(b);
				if(rem >= N) {
//					continue;
					if(bst2.count(rem)){
						string ns2 = ns + "+" + bst2[rem];
						if(sz(ans) > sz(ns2)) ans = ns2;
					}
			//		continue;
				}
				if(rem == 0){
					if(sz(ans) > sz(ns)) ans = ns;
				}
				if(rem > 0 && rem < N){
					ns += "+" + bst[rem];
					if(sz(ans) > sz(ns)) ans = ns;
				}

			}

		}
	}

	cout << ans << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    int tt = clock();
#endif
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
	precalc();
    int tc = 1;
	//cin >> tc;
    while(tc--) {
    	read();
        solve();

#ifdef _DEBUG
        cerr << "TIME = " << clock() - tt << endl;
        tt = clock();
#endif
    }

    return 0;
}


#include <bits/stdc++.h>

#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forn(i, n) fore(i, 0, n)
#define nfor(i, n) for(int i = int(n) - 1; i >= 0; --i)
#define for1(i, n) for(int i = 1; i < int(n); ++i)

#define mp make_pair
#define pb push_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define x first
#define y second

#define correct(x, y, xmax, ymax) ((x) >= 0 && (x) < (xmax) && (y) >= 0 && (y) < (ymax))
//#define max(a, b) ((a > b)? a : b)
//#define min(a, b) ((a < b)? a : b)
//#define abs(a) ((a < 0) ? -a : a)
//#define sqr(a) (a * a)

using namespace std;

template<class T> T gcd(T a, T b) { while(a > 0){ b %= a; swap(a, b);} return b; }
template<class T> T lcm(T a, T b) { return a / gcd (a, b) * b; }
template<class T> T sign(T a) { return a > 0 ? 1 : (a < 0 ? -1 : 0); }

template<class A, class B> ostream& operator <<(ostream &out, const pair<A, B> &p) {
    return out << "(" << p.x << ", " << p.y << ")";
};

template<class A> ostream& operator <<(ostream &out, const vector<A> &v) {
    out << "[";
    forn(i, sz(v)) {
        if(i)
            out << ", ";
        out << v[i];
    }
    return out << "]";
}

mt19937 myRand(time(NULL)); // [0, 2^32)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;
typedef vector <int> vi;

const int dx[] = {-1, 0, 1,  0};
const int dy[] = { 0, 1, 0, -1};
const int dxK[] = {-1, -1, 0, 1, 1,  1,  0, -1};
const int dyK[] = { 0,  1, 1, 1, 0, -1, -1, -1};
const int dxKn[] = {-2, -1, 1, 2,  2,  1, -1, -2};
const int dyKn[] = { 1,  2, 2, 1, -1, -2, -2, -1};

const int INF = int(1e9) + 100;
const li INF64 = li(1e18) + 100;
const ld EPS = 1e-9;
const ld PI = acosl(-1.0);
const int N = 400009;

li n;
string s;
string bst[N];
map<li, string> bst2;

string tos(li a){
	if(a == 0) return "0";
	string res = "";
	while(a > 0) res += '0' + (a % 10), a /= 10;
	reverse(all(res));
	return res;
}

void precalc(){
	for(int i = 1; i < N; ++i) bst[i] = tos(i);
	for(int i = 2; i < N; ++i){
		li cur = i * 1LL * i;
		for(int x = 2; cur < N; cur *= i, ++x){
			string ns = tos(i) + "^" + tos(x);
			if(sz(ns) < sz(bst[cur])) bst[cur] = ns;
		}
	}

	for(int i = 2; i < N; ++i){
		for(int j = 2; j * j <= i; ++j){
			if(i % j != 0) continue;
			{
				int c = j;
				int c2 = i / j;
				string ns = bst[c] + "*" + bst[c2];
				if(sz(ns) < sz(bst[i])) bst[i] = ns;
			}
			{
				int c = i / j;
				int c2 = j;
				string ns = bst[c] + "*" + bst[c2];
				if(sz(ns) < sz(bst[i])) bst[i] = ns;
			}
		}
	}
//return;
	for(int i = 2; i < N; ++i){
		li cur = i * 1LL * i;
		for(int x = 2; cur < 20000000000; cur *= i, ++x){
			string ns = tos(i) + "^" + tos(x);
			if(!bst2.count(cur) || sz(bst2[cur]) > sz(ns))
				bst2[cur] = ns;
		}
	}
}

inline bool read() {
    if(!(cin >> s))
    	return false;
    return true;
}

string ans;

inline void solve() {
	//n = atoi(s.c_str());
//	cout << bst2[1953125] << endl;
	li n = 0;
	forn(i, sz(s)) n = 10LL * n + s[i] - '0';
//	cout << n << endl;
	ans = s;
	for(li a = 2; a <= 100002; ++a){
		li cur = a * a;

		for(li b = 2; cur <= n; ++b, cur *= a){
			for(li c = 2; c <= 100; ++c){
				li p = c * cur;
				li rem = n - p;
				if(rem < 0) break;
				string ns = tos(c) + "*" + tos(a) + "^" + tos(b);
				if(rem >= N) {
//					continue;
					if(bst2.count(rem)){
						string ns2 = ns + "+" + bst2[rem];
						if(sz(ans) > sz(ns2)) ans = ns2;
					}
					continue;
				}

				if(rem > 0){
					ns += "+" + bst[rem];
				}

				if(sz(ans) > sz(ns)) ans = ns;
			}

			{
				li p = cur;
				li rem = n - p;
				if(rem < 0) break;
				string ns = tos(a) + "^" + tos(b);
				if(rem >= N) {
//					continue;
					if(bst2.count(rem)){
						string ns2 = ns + "+" + bst2[rem];
						if(sz(ans) > sz(ns2)) ans = ns2;
					}
					continue;
				}

				if(rem > 0){
					ns += "+" + bst[rem];
				}

				if(sz(ans) > sz(ns)) ans = ns;
			}
		}
	}

	cout << ans << endl;
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    int tt = clock();
#endif
    cout << fixed << setprecision(15);
    cerr << fixed << setprecision(15);
	precalc();
    int tc = 1;
	//cin >> tc;
    while(tc--) {
    	read();
        solve();

#ifdef _DEBUG
        cerr << "TIME = " << clock() - tt << endl;
        tt = clock();
#endif
    }

    return 0;
}