#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
  return s * w;
}
int n, m;
int val[N][2];
struct node {
  int to, a, b, id;
};
vector<node> e[N];
int cnt, col[N], cntx;
int cnt_edge, deg[N];
int f[N][2][2], g[N][2];
void add(int &x, int y) { x = x + y - (x + y >= mod ? mod : 0); }
void dfs_chain(int x, int st) {
  ++cntx;
  col[x] = cnt;
  if (x == st) f[cntx][0][val[x][0]] = f[cntx][1][val[x][1]] = 1;
  for (int i = 0; i < e[x].size(); i++) {
    node p = e[x][i];
    if (col[p.to]) continue;
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        for (int l = 0; l < 2; l++)
          add(f[cntx + 1][l][k ^ ((j ^ p.a) | (l ^ p.b)) ^ val[p.to][l]],
              f[cntx][j][k]);
    dfs_chain(p.to, st);
  }
}
void init() {
  for (int i = 1; i <= cntx; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++) f[i][j][k] = 0;
}
int book[2][N];
void dfs_cir(int x, int st, int c) {
  ++cntx;
  col[x] = cnt;
  if (x == st) f[cntx][c][val[x][c]] = 1;
  for (int i = 0; i < e[x].size(); i++) {
    node p = e[x][i];
    if (book[c][p.id]) continue;
    book[c][p.id] = 1;
    if (p.to == st) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          int op = (k ^ ((j ^ p.a) | (c ^ p.b)));
          add(g[cnt][op], f[cntx][j][k]);
        }
      }
    } else {
      for (int j = 0; j < 2; j++)
        for (int k = 0; k < 2; k++)
          for (int l = 0; l < 2; l++)
            add(f[cntx + 1][l][k ^ ((j ^ p.a) | (l ^ p.b)) ^ val[p.to][l]],
                f[cntx][j][k]);
      dfs_cir(p.to, st, c);
    }
  }
}
int h[N][2];
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    int k = read();
    if (k == 1) {
      int x = read();
      if (x < 0)
        val[-x][0] ^= 1;
      else
        val[x][1] ^= 1;
    } else {
      int x = read(), y = read();
      if (abs(x) == abs(y)) {
        if (x < 0 && y < 0)
          val[abs(x)][0] ^= 1;
        else if (x > 0 && y > 0)
          val[abs(x)][1] ^= 1;
        else
          val[abs(x)][0] ^= 1, val[abs(x)][1] ^= 1;
        continue;
      }
      ++cnt_edge;
      e[abs(x)].push_back((node){abs(y), (x < 0), (y < 0), cnt_edge});
      e[abs(y)].push_back((node){abs(x), (y < 0), (x < 0), cnt_edge});
      deg[abs(x)]++;
      deg[abs(y)]++;
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!col[i] && deg[i] <= 1) {
      ++cnt;
      cntx = 0;
      dfs_chain(i, i);
      g[cnt][0] = (f[cntx][0][0] + f[cntx][1][0]) % mod;
      g[cnt][1] = (f[cntx][0][1] + f[cntx][1][1]) % mod;
      init();
    }
  }
  for (int i = 1; i <= m; i++) {
    if (!col[i]) {
      ++cnt;
      cntx = 0;
      dfs_cir(i, i, 0);
      init();
      cntx = 0;
      dfs_cir(i, i, 1);
      init();
    }
  }
  h[0][0] = 1;
  for (int i = 1; i <= cnt; i++)
    for (int j = 0; j < 2; j++)
      for (int k = 0; k < 2; k++)
        add(h[i][j], 1ll * h[i - 1][k] * g[i][j ^ k] % mod);
  cout << h[cnt][1] << endl;
  return 0;
}
