#include <bits/stdc++.h>
const int N = 100005, mu = 1e9 + 7;
int g[2][2][2], st[N], tp, a[N][2], type[N], vis[N], c[2], dp[2][2];
int d[N], n, m, k, x;
std::vector<int> e[N], v[N];
void reduce(int &x) { x += x >> 31 & mu; }
void dfs(int x) {
  vis[x] = 1, st[++tp] = x;
  for (auto u : e[x])
    if (!vis[u]) dfs(u);
}
void Dp(int sl, int sr, int tl, int tr) {
  int now = 0;
  memset(g[now], 0, sizeof(g[now]));
  for (int i = sl; i <= sr; i++) g[now][0][i] = 1;
  int x = st[1], nxt = st[2];
  if ((!a[x][1]) ||
      (abs(a[x][1]) != abs(a[nxt][0])) && (abs(a[x][1]) != abs(a[nxt][1])))
    std::swap(a[x][0], a[x][1]);
  for (int i = 2; i <= tp; i++)
    if (abs(a[st[i - 1]][1]) != abs(a[st[i]][0]))
      std::swap(a[st[i]][0], a[st[i]][1]);
  for (int i = 1; i <= tp; i++) {
    int x = st[i];
    now = now ^ 1;
    memset(g[now], 0, sizeof(g[now]));
    for (int lst = 0; lst <= 1; lst++)
      for (int s = 0; s <= 1; s++) {
        int t = g[now ^ 1][s][lst];
        if (!t) continue;
        for (int j = 0; j <= 1; j++) {
          int l = lst, r = j;
          if (a[x][0] < 0) l = l ^ 1;
          if (a[x][1] < 0) r = r ^ 1;
          reduce(g[now][s ^ (l | r)][j] += t - mu);
        }
      }
  }
  for (int i = 0; i <= 1; i++)
    for (int j = tl; j <= tr; j++) reduce(c[i] += g[now][i][j] - mu);
}
void solve(int x) {
  c[0] = c[1] = 0;
  tp = 0;
  dfs(x);
  if (tp == 1) {
    int t = st[1];
    if (type[t] == 1)
      c[0] = c[1] = 1;
    else {
      if (abs(a[t][0]) != abs(a[t][1]))
        c[0] = 1, c[1] = 3;
      else if (a[t][0] == a[t][1])
        c[0] = c[1] = 1;
      else
        c[1] = 2;
    }
    return;
  }
  int rt = 0;
  for (int i = 1; i <= tp; i++)
    if (d[st[i]] == 1) rt = st[i];
  if (rt) {
    for (int i = 1; i <= tp; i++) vis[st[i]] = 0;
    tp = 0, dfs(rt);
    int x = st[1], sl = 0, sr = 1, tl = 0, tr = 1;
    if (type[x] == 1) sr = 0, type[x] = 2;
    x = st[tp];
    if (type[x] == 1) tr = 0, type[x] = 2;
    Dp(sl, sr, tl, tr);
    return;
  }
  Dp(0, 0, 0, 0), Dp(1, 1, 1, 1);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    type[i] = k;
    for (int j = 0; j < k; j++) {
      scanf("%d", &x);
      a[i][j] = x;
      v[abs(x)].push_back(i);
    }
  }
  int ans = 1;
  for (int i = 1; i <= m; i++)
    if (!(v[i].size()))
      ans = ans * 2ll % mu;
    else if (v[i].size() == 2) {
      int x = v[i][0], y = v[i][1];
      e[x].push_back(y), e[y].push_back(x);
      d[x]++, d[y]++;
    }
  dp[0][0] = 1;
  int now = 0;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    solve(i);
    now = now ^ 1, dp[now][0] = dp[now][1] = 0;
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k <= 1; k++)
        reduce(dp[now][j ^ k] += (long long)dp[now ^ 1][j] * c[k] % mu - mu);
  }
  ans = (long long)ans * dp[now][1] % mu;
  printf("%d\n", ans);
}
