#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 10;
int a[maxn][maxn], r[maxn], c[maxn], rr[maxn], cc[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      r[i] += a[i][j];
      c[j] += a[i][j];
    }
  while (true) {
    bool fin = true;
    for (int i = 0; i < n; i++) {
      if (r[i] < 0) {
        fin = false;
        r[i] = -r[i];
        rr[i] = 1 - rr[i];
        for (int j = 0; j < m; j++) {
          c[j] -= 2 * a[i][j];
          a[i][j] = -a[i][j];
        }
      }
    }
    for (int i = 0; i < m; i++) {
      if (c[i] < 0) {
        fin = false;
        c[i] = -c[i];
        cc[i] = 1 - cc[i];
        for (int j = 0; j < n; j++) {
          r[j] -= 2 * a[j][i];
          a[j][i] = -a[j][i];
        }
      }
    }
    if (fin) break;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++)
    if (rr[i] & 1) cnt++;
  cout << cnt << " ";
  for (int i = 0; i < n; i++)
    if (rr[i] & 1) cout << i + 1 << " ";
  cout << endl;
  cnt = 0;
  for (int i = 0; i < m; i++)
    if (cc[i] & 1) cnt++;
  cout << cnt << " ";
  for (int i = 0; i < m; i++)
    if (cc[i]) cout << i + 1 << " ";
  cout << endl;
  return 0;
}
