#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
  return x * f;
}
const int MAXN = 200010;
const int INF = 2147483600;
const long long Mod = 1e9 + 7;
int N, M;
bool been[MAXN + 1];
int sta[MAXN + 1], top;
long long f[2], fn[2];
int In[MAXN + 1];
int vis[MAXN + 1];
long long g[MAXN + 1][2][2];
int Node[MAXN << 1], Next[MAXN << 1], Root[MAXN + 1], cnt;
bool chs[MAXN + 1];
inline void insert(int u, int v) {
  u = abs(u), v = abs(v);
  In[u]++;
  Node[++cnt] = v;
  Next[cnt] = Root[u];
  Root[u] = cnt;
}
inline void dfs(int k) {
  been[k] = 1;
  sta[++top] = k;
  for (int x = Root[k]; x; x = Next[x]) {
    int v = Node[x];
    if (been[v]) continue;
    dfs(v);
  }
}
inline long long pls(long long a, long long b) {
  return (a + b >= Mod ? a + b - Mod : a + b);
}
inline void Add(long long &a, long long b) {
  a = (a + b >= Mod ? a + b - Mod : a + b);
}
int main() {
  N = read(), M = read();
  for (int i = 1; i <= N; i++) {
    int K = read();
    if (K == 1) {
      int x = read();
      chs[abs(x)] = 1;
      vis[abs(x)] += x;
    } else {
      int u = read(), v = read();
      chs[abs(u)] = chs[abs(v)] = 1;
      vis[abs(u)] += u;
      vis[abs(v)] += v;
      insert(u, v);
      insert(v, u);
    }
  }
  swap(N, M);
  f[0] = 1;
  for (int i = 1; i <= N; i++) vis[i] = abs(vis[i]) / i;
  for (int i = 1; i <= N; i++) {
    if (!In[i]) {
      if (!vis[i]) {
        if (chs[i]) swap(f[0], f[1]);
        f[0] = pls(f[0], f[0]), f[1] = pls(f[1], f[1]);
      } else if (vis[i] == 1)
        f[0] = f[1] = pls(f[0], f[1]);
      else
        f[0] = pls(f[0], f[0]), f[1] = pls(f[1], f[1]);
      continue;
    }
    if (been[i]) continue;
    fn[0] = fn[1] = 0;
    if (In[i] == 1) {
      top = 0;
      dfs(i);
      for (int t = 1; t <= top; t++)
        for (int j = 0; j < 2; j++)
          for (int k = 0; k < 2; k++) g[t][j][k] = 0;
      if (vis[sta[1]] == 1)
        g[1][0][1] = g[1][0][0] = 1;
      else
        g[1][0][0] = g[1][1][1] = 1;
      for (int j = 1; j < top; j++) {
        for (int d = 0; d < 2; d++) {
          for (int s0 = 0; s0 < 2; s0++) {
            if (!g[j][d][s0]) continue;
            int s1 = s0 ^ (vis[sta[j]] != 2);
            for (int s2 = 0; s2 < 2; s2++)
              Add(g[j + 1][d ^ (s1 | s2)][s2], g[j][d][s0]);
          }
        }
      }
      if (vis[sta[top]] != 1) {
        for (int last = 0; last < 2; last++)
          for (int d = 0; d < 2; d++) {
            for (int s0 = 0; s0 < 2; s0++) {
              if (!g[top][d][s0]) continue;
              int s1 = s0 ^ (vis[sta[top]] != 2);
              Add(fn[d ^ last ^ s1], f[last] * g[top][d][s0] % Mod);
            }
          }
      } else {
        for (int last = 0; last < 2; last++)
          for (int d = 0; d < 2; d++) {
            for (int s0 = 0; s0 < 2; s0++) {
              if (!g[top][d][s0]) continue;
              Add(fn[d ^ last], f[last] * g[top][d][s0] % Mod);
            }
          }
      }
      f[0] = fn[0], f[1] = fn[1];
    }
  }
  for (int i = 1; i <= N; i++) {
    fn[0] = fn[1] = 0;
    if (In[i] == 2 && !been[i]) {
      top = 0;
      dfs(i);
      for (int c = 0; c < 2; c++) {
        for (int t = 1; t <= top; t++)
          for (int j = 0; j < 2; j++)
            for (int k = 0; k < 2; k++) g[t][j][k] = 0;
        g[1][0][c] = 1;
        for (int j = 1; j < top; j++) {
          for (int d = 0; d < 2; d++) {
            for (int s0 = 0; s0 < 2; s0++) {
              if (!g[j][d][s0]) continue;
              int s1 = s0 ^ (vis[sta[j]] != 2);
              for (int s2 = 0; s2 < 2; s2++)
                Add(g[j + 1][d ^ (s1 | s2)][s2], g[j][d][s0]);
            }
          }
        }
        for (int last = 0; last < 2; last++)
          for (int d = 0; d < 2; d++) {
            for (int s0 = 0; s0 < 2; s0++) {
              int s1 = s0 ^ (vis[sta[top]] != 2);
              Add(fn[d ^ last ^ (s1 | c)], f[last] * g[top][d][s0] % Mod);
            }
          }
      }
      f[0] = fn[0], f[1] = fn[1];
    }
  }
  printf("%lld\n", f[1]);
  return 0;
}
