#include <bits/stdc++.h>
using namespace std;
int lst[100005], to[200005], pre[200005], idx[200005], tot, deg[100005];
int seq[100005], cnt, vis[100005], st[100005][2], tp;
int dp[100005][2][2], dp2[100005][2][2][2], f[100005][2];
int a[100005], b[100005];
bool del[200005], dfs_vis[100005];
inline void upd(int &x, int y) {
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
inline void add_edge(int u, int v, int _idx) {
  to[tot] = v;
  pre[tot] = lst[u];
  idx[tot] = _idx;
  deg[v]++;
  lst[u] = tot++;
}
inline int calc(int v, int x, int y) {
  if (to[v] != ((b[idx[v]]) < 0 ? -(b[idx[v]]) : (b[idx[v]]))) swap(x, y);
  if (a[idx[v]] < 0) x ^= 1;
  if (b[idx[v]] < 0) y ^= 1;
  return x | y;
}
void dfs(int u) {
  if (dfs_vis[u]) return;
  dfs_vis[u] = true;
  for (int i = lst[u]; ~i; i = pre[i]) {
    if (del[i]) continue;
    seq[cnt++] = i;
    del[i] = del[i ^ 1] = true;
    dfs(to[i]);
  }
}
int main() {
  memset(lst, -1, sizeof(lst));
  int n, m, neg = 0, ans = 1;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    int len;
    scanf("%d", &len);
    if (len == 1) {
      scanf("%d", a + i);
      if (vis[((a[i]) < 0 ? -(a[i]) : (a[i]))]) {
        st[tp][0] = 0;
        st[tp--][1] = 0;
        (ans <<= 1) %= 1000000007;
        continue;
      }
      vis[((a[i]) < 0 ? -(a[i]) : (a[i]))] = a[i];
      if (!deg[((a[i]) < 0 ? -(a[i]) : (a[i]))]) {
        st[++tp][0] = 1;
        st[tp][1] = 1;
      }
      continue;
    }
    scanf("%d%d", a + i, b + i);
    if (a[i] == -b[i]) {
      neg++;
      vis[((a[i]) < 0 ? -(a[i]) : (a[i]))] = 1;
      (ans <<= 1) %= 1000000007;
      continue;
    }
    int x = ((a[i]) < 0 ? -(a[i]) : (a[i])),
        y = ((b[i]) < 0 ? -(b[i]) : (b[i]));
    if (x == y) {
      vis[x] = 1;
      st[++tp][0] = 1;
      st[tp][1] = 1;
      continue;
    }
    add_edge(x, y, i);
    add_edge(y, x, i);
    if (vis[x]) {
      st[tp][0] = 0;
      st[tp--][1] = 0;
    }
    if (vis[y]) {
      st[tp][0] = 0;
      st[tp--][1] = 0;
    }
  }
  for (int u = 1; u <= m; u++) {
    if (dfs_vis[u] || deg[u] == 2) continue;
    if (!deg[u] && !vis[u]) {
      (ans <<= 1) %= 1000000007;
      continue;
    }
    if (!deg[u]) continue;
    cnt = 0;
    dfs(u);
    for (int j = 0; j < cnt; j++) memset(dp[j], 0, sizeof(dp[j]));
    if (vis[u] < 0) {
      dp[0][0][calc(seq[0], 0, 0) ^ 1]++;
      dp[0][1][calc(seq[0], 0, 1) ^ 1]++;
      dp[0][0][calc(seq[0], 1, 0)]++;
      dp[0][1][calc(seq[0], 1, 1)]++;
    } else if (vis[u] > 0) {
      dp[0][0][calc(seq[0], 0, 0)]++;
      dp[0][1][calc(seq[0], 0, 1)]++;
      dp[0][0][calc(seq[0], 1, 0) ^ 1]++;
      dp[0][1][calc(seq[0], 1, 1) ^ 1]++;
    } else {
      dp[0][0][calc(seq[0], 0, 0)]++;
      dp[0][1][calc(seq[0], 0, 1)]++;
      dp[0][0][calc(seq[0], 1, 0)]++;
      dp[0][1][calc(seq[0], 1, 1)]++;
    }
    for (int i = 1; i < cnt; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          for (int x = 0; x < 2; x++)
            upd(dp[i][j][x ^ calc(seq[i], k, j)], dp[i - 1][k][x]);
        }
      }
    }
    tp++;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (vis[to[seq[cnt - 1]]])
          upd(st[tp][i ^ j ^ (vis[to[seq[cnt - 1]]] < 0)], dp[cnt - 1][i][j]);
        else
          upd(st[tp][j], dp[cnt - 1][i][j]);
      }
    }
  }
  for (int u = 1; u <= m; u++) {
    if (dfs_vis[u] || deg[u] != 2) continue;
    cnt = 0;
    dfs(u);
    for (int i = 0; i < cnt; i++) memset(dp2[i], 0, sizeof(dp2[i]));
    dp2[0][0][0][calc(seq[0], 0, 0)]++;
    dp2[0][0][1][calc(seq[0], 0, 1)]++;
    dp2[0][1][0][calc(seq[0], 1, 0)]++;
    dp2[0][1][1][calc(seq[0], 1, 1)]++;
    for (int i = 1; i < cnt - 1; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          for (int x = 0; x < 2; x++) {
            for (int y = 0; y < 2; y++)
              upd(dp2[i][j][x][y ^ calc(seq[i], k, x)], dp2[i - 1][j][k][y]);
          }
        }
      }
    }
    tp++;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++)
          upd(st[tp][k ^ calc(seq[cnt - 1], j, i)], dp2[cnt - 2][i][j][k]);
      }
    }
  }
  f[0][0] = ans;
  for (int i = 1; i <= tp; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++)
        upd(f[i][j ^ k], (long long)f[i - 1][j] * st[i][k] % 1000000007);
    }
  }
  printf("%d\n", f[tp][neg & 1 ^ 1]);
  return 0;
}
