#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 100010;
int dp[2][2][2];
int dp_[2][2][2];
int f[2], g[2];
int ans[2];
int vis[N];
struct data {
  int x, y;
  data() {}
  data(int x, int y) : x(x), y(y) {}
};
data a[N][3], b[N][3];
int cnt[N];
int kk[N];
void copy() {
  int p1, p2, opt;
  for (p1 = 0; p1 <= 1; p1++)
    for (p2 = 0; p2 <= 1; p2++)
      for (opt = 0; opt <= 1; opt++) dp[p1][p2][opt] = dp_[p1][p2][opt];
}
void calc() {
  int p1, p2;
  g[0] = g[1] = 0;
  for (p1 = 0; p1 <= 1; p1++) {
    for (p2 = 0; p2 <= 1; p2++) {
      g[p1 ^ p2] = (g[p1 ^ p2] + 1ll * ans[p1] * f[p2]) % mod;
    }
  }
  ans[0] = g[0];
  ans[1] = g[1];
}
void SWAP() {
  int p1, p2, opt;
  memset(dp_, 0, sizeof(dp_));
  for (p1 = 0; p1 <= 1; p1++)
    for (p2 = 0; p2 <= 1; p2++)
      for (opt = 0; opt <= 1; opt++) dp_[p1][p2][opt] = dp[p2][p1][opt];
  copy();
}
void print() {
  int p1, p2, opt;
  for (p1 = 0; p1 <= 1; p1++)
    for (p2 = 0; p2 <= 1; p2++)
      for (opt = 0; opt <= 1; opt++)
        if (dp[p1][p2][opt])
          printf("dp[%d][%d][%d]=%d\n", p1, p2, opt, dp[p1][p2][opt]);
  printf("==============================\n");
}
int main() {
  int n, m;
  int i, k1, k2, c1, c2, p1, p2, opt, h1, h2, x, y, j, tmp, next;
  int t1, t2;
  ans[0] = 1;
  ans[1] = 0;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &kk[i]);
    for (j = 1; j <= kk[i]; j++) {
      scanf("%d", &a[i][j].x);
      if (a[i][j].x > 0)
        a[i][j].y = 0;
      else
        a[i][j].y = 1;
      x = abs(a[i][j].x);
      b[x][++cnt[x]] = a[i][j].x > 0 ? data(i, 0) : data(i, 1);
      a[i][j].x = abs(a[i][j].x);
    }
  }
  vis[0] = 1;
  for (i = 1; i <= m; i++)
    if (b[i][1].x == 0 && b[i][2].x == 0) vis[i] = 1;
  for (i = 1; i <= m; i++)
    if (!vis[i]) {
      memset(dp, 0, sizeof(dp));
      h1 = i;
      h2 = i;
      k1 = b[i][1].x;
      c1 = b[i][1].y;
      k2 = b[i][2].x;
      c2 = b[i][2].y;
      y = 0;
      dp[c1 ^ y][c2 ^ y][0] = 1;
      y = 1;
      dp[c1 ^ y][c2 ^ y][0] = 1;
      vis[i] = 1;
      if (k1 == k2) {
        f[0] = f[1] = 0;
        for (p1 = 0; p1 <= 1; p1++)
          for (p2 = 0; p2 <= 1; p2++)
            for (opt = 0; opt <= 1; opt++)
              f[opt ^ (p1 | p2)] = (f[opt ^ (p1 | p2)] + dp[p1][p2][opt]) % mod;
        calc();
        continue;
      }
      if (kk[k2] == 1) {
        memset(dp_, 0, sizeof(dp_));
        for (p1 = 0; p1 <= 1; p1++)
          for (p2 = 0; p2 <= 1; p2++)
            for (opt = 0; opt <= 1; opt++)
              dp_[p1][p2][opt ^ p2] =
                  (dp_[p1][p2][opt ^ p2] + dp[p1][p2][opt]) % mod;
        copy();
        k2 = 0;
      }
      while (true) {
        if (k1 == 0 && k2 == 0) {
          f[0] = f[1] = 0;
          for (p1 = 0; p1 <= 1; p1++)
            for (p2 = 0; p2 <= 1; p2++)
              for (opt = 0; opt <= 1; opt++)
                f[opt] = (f[opt] + dp[p1][p2][opt]) % mod;
          calc();
          break;
        }
        if (kk[k1] == 1) {
          k1 = 0;
          swap(k1, k2);
          swap(h1, h2);
          memset(dp_, 0, sizeof(dp_));
          for (p1 = 0; p1 <= 1; p1++)
            for (p2 = 0; p2 <= 1; p2++)
              for (opt = 0; opt <= 1; opt++)
                dp_[p1][p2][opt ^ p1] =
                    (dp_[p1][p2][opt ^ p1] + dp[p1][p2][opt]) % mod;
          copy();
          SWAP();
          continue;
        }
        x = a[k1][1].x + a[k1][2].x - h1;
        if (cnt[x] == 1) {
          memset(dp_, 0, sizeof(dp_));
          for (y = 0; y <= 1; y++)
            for (p1 = 0; p1 <= 1; p1++)
              for (p2 = 0; p2 <= 1; p2++)
                for (opt = 0; opt <= 1; opt++) {
                  tmp = p1 | y;
                  dp_[y][p2][opt ^ tmp] =
                      (dp_[y][p2][opt ^ tmp] + dp[p1][p2][opt]) % mod;
                }
          copy();
          SWAP();
          k1 = 0;
          swap(k1, k2);
          swap(h1, h2);
          vis[x] = 1;
          continue;
        }
        next = b[x][1].x + b[x][2].x - k1;
        c1 = b[x][1].y;
        c2 = b[x][2].y;
        memset(dp_, 0, sizeof(dp_));
        for (y = 0; y <= 1; y++) {
          for (p1 = 0; p1 <= 1; p1++) {
            for (p2 = 0; p2 <= 1; p2++) {
              for (opt = 0; opt <= 1; opt++) {
                t1 = c1 ^ y;
                t2 = c2 ^ y;
                tmp = t1 | p1;
                dp_[t2][p2][opt ^ tmp] =
                    (dp_[t2][p2][opt ^ tmp] + dp[p1][p2][opt]) % mod;
              }
            }
          }
        }
        copy();
        k1 = next;
        h1 = x;
        vis[x] = 1;
        if (k1 == k2 && k1 != 0) {
          f[0] = f[1] = 0;
          for (p1 = 0; p1 <= 1; p1++)
            for (p2 = 0; p2 <= 1; p2++)
              for (opt = 0; opt <= 1; opt++)
                f[opt ^ (p1 | p2)] =
                    (f[opt ^ (p1 | p2)] + dp[p1][p2][opt]) % mod;
          calc();
          break;
        }
      }
    }
  for (i = 1; i <= m; i++)
    if (b[i][1].x == 0 && b[i][2].x == 0) {
      ans[1] = 1ll * ans[1] * 2 % mod;
    }
  printf("%d", ans[1]);
}
