#include <bits/stdc++.h>
using namespace std;
bool rr[110], rc[110];
int sr[110], sc[110];
int in[110][110];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  ;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) scanf("%d", &in[i][j]);
  while (1) {
    memset(sr, 0, sizeof(sr));
    memset(sc, 0, sizeof(sc));
    for (int i = 0; i < (n); i++)
      for (int j = 0; j < (m); j++) {
        int a = in[i][j];
        if (rr[i] ^ rc[j]) a = -a;
        sr[i] += a;
        sc[j] += a;
      }
    bool f = 0;
    int mi = 0, mp = 0, mp2 = 0;
    for (int i = 0; i < (n); i++)
      if (sr[i] < mi) {
        mp = i;
        mp2 = 0;
        mi = sr[i];
        f = 1;
      }
    for (int j = 0; j < (m); j++)
      if (sc[j] < 0) {
        f = 1;
        mp = j;
        mp2 = 1;
        mi = sc[j];
      }
    if (!f) break;
    if (mp2)
      rc[mp] ^= 1;
    else
      rr[mp] ^= 1;
  }
  int c1 = 0, c2 = 0;
  for (int i = 0; i < (n); i++)
    if (rr[i]) c1++;
  printf("%d", c1);
  for (int i = 0; i < (n); i++)
    if (rr[i]) printf(" %d", i + 1);
  puts("");
  for (int i = 0; i < (m); i++)
    if (rc[i]) c2++;
  printf("%d", c2);
  for (int i = 0; i < (m); i++)
    if (rc[i]) printf(" %d", i + 1);
  puts("");
}
