#include <bits/stdc++.h>
using namespace std;
int a[103][103], m, n;
int h[103], l[103], markh[103], markl[103];
int find() {
  for (int i = 1; i <= n; i++)
    if (h[i] < 0) return i;
  return 0;
}
int find1() {
  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 = find()) || (t1 = find1())) {
    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");
}
