#include <bits/stdc++.h>
template <class T_T>
T_T gcd(T_T a, T_T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T_T>
T_T f_max(T_T a, T_T b) {
  return a > b ? a : b;
}
using namespace std;
const int N = 100000;
int a[105][105], r[105], c[105], cnt_r[105], cnt_c[105], ans;
int main() {
  int n, m, i, j;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      r[i] += a[i][j];
      c[j] += a[i][j];
    }
  queue<int> q;
  for (i = 1; i <= n; i++)
    if (r[i] < 0) q.push(i);
  for (i = 1; i <= m; i++)
    if (c[i] < 0) q.push(i + n);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    if (v <= n) {
      if (r[v] >= 0) continue;
      cnt_r[v]++;
      r[v] = -r[v];
      for (i = 1; i <= m; i++) {
        c[i] -= 2 * a[v][i];
        a[v][i] = -a[v][i];
        if (c[i] < 0) q.push(i + n);
      }
    } else {
      v -= n;
      if (c[v] >= 0) continue;
      cnt_c[v]++;
      c[v] = -c[v];
      for (i = 1; i <= n; i++) {
        r[i] -= 2 * a[i][v];
        a[i][v] = -a[i][v];
        if (r[i] < 0) q.push(i);
      }
    }
  }
  for (i = 1, ans = 0; i <= n; i++)
    if (cnt_r[i] & 1) ans++;
  printf("%d ", ans);
  for (i = 1; i <= n; i++)
    if (cnt_r[i] & 1) printf("%d ", i);
  puts("");
  for (i = 1, ans = 0; i <= m; i++)
    if (cnt_c[i] & 1) ans++;
  printf("%d ", ans);
  for (i = 1; i <= m; i++)
    if (cnt_c[i] & 1) printf("%d ", i);
  puts("");
}
