#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &num) {
  num = 0;
  T f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') num = num * 10 + ch - '0', ch = getchar();
  num *= f;
}
const int maxn = 1e5 + 5, mod = 1e9 + 7;
int n, m, sz, cir;
int a[maxn][2], cnt[maxn], vis[maxn], toti[maxn], totj[maxn], used[maxn];
int ans0, ans1, f[maxn][2][2][2];
int q[maxn][2];
void dfs(int i, int j) {
  vis[i] = 1;
  sz++;
  for (int(k) = (0); (k) < (cnt[i]); (k)++) {
    if (a[i][k] > 0) {
      if (j)
        q[sz][cnt[i] - 1 - k] = 0;
      else
        q[sz][k] = 0;
    } else {
      if (j)
        q[sz][cnt[i] - 1 - k] = 1;
      else
        q[sz][k] = 1;
    }
  }
  int tail = abs(a[i][cnt[i] - 1 - j]);
  int nxti = toti[tail] - i, nxtj = totj[tail] - (cnt[i] - 1 - j);
  if (!nxti) return;
  if (!vis[nxti])
    dfs(nxti, nxtj);
  else if (cnt[i] == 2)
    cir = 1;
}
int add(int x, int y) { return x + y >= mod ? x + y - mod : x + y; }
void upd(int &x, int y) { x = add(x, y); }
void DP() {
  for (int(i) = (0); (i) <= (sz); (i)++) memset(f[i], 0, sizeof f[i]);
  f[0][0][0][0] = f[0][1][0][1] = 1;
  for (int(i) = (0); (i) <= (sz - 1); (i)++)
    for (int(j) = (0); (j) <= (1); (j)++)
      for (int(k) = (0); (k) <= (1); (k)++)
        for (int(l) = (0); (l) <= (1); (l)++) {
          int nxti = i + 1, nxtl = l;
          if ((!i) && (q[nxti][1] == -1)) {
            int x1 = j ^ q[nxti][0];
            int nxtj = j, nxtk = k ^ x1;
            upd(f[nxti][nxtj][nxtk][nxtl], f[i][j][k][l]);
          } else if ((i == sz - 1) && (q[nxti][1] == -1)) {
            int x1 = j ^ q[nxti][0];
            int nxtj = j, nxtk = k ^ x1;
            upd(f[nxti][nxtj][nxtk][nxtl], f[i][j][k][l]);
          } else {
            for (int(nxtj) = (0); (nxtj) <= (1); (nxtj)++) {
              int x1 = j ^ q[nxti][0], x2 = nxtj ^ q[nxti][1];
              if (q[nxti][0] == -1) assert(0);
              if (q[nxti][1] == -1) assert(0);
              int nxtk = k ^ (x1 | x2);
              upd(f[nxti][nxtj][nxtk][nxtl], f[i][j][k][l]);
            }
          }
        }
  if (!cir) {
    int now0 = 0, now1 = 0;
    for (int(j) = (0); (j) <= (1); (j)++)
      for (int(l) = (0); (l) <= (1); (l)++)
        upd(now0, f[sz][j][0][l]), upd(now1, f[sz][j][1][l]);
    int nans0 = (1ll * ans0 * now0 + 1ll * ans1 * now1) % mod,
        nans1 = (1ll * ans0 * now1 + 1ll * ans1 * now0) % mod;
    ans0 = nans0;
    ans1 = nans1;
  } else {
    int now0 = 0, now1 = 0;
    for (int(l) = (0); (l) <= (1); (l)++)
      upd(now0, f[sz][l][0][l]), upd(now1, f[sz][l][1][l]);
    int nans0 = (1ll * ans0 * now0 + 1ll * ans1 * now1) % mod,
        nans1 = (1ll * ans0 * now1 + 1ll * ans1 * now0) % mod;
    ans0 = nans0;
    ans1 = nans1;
  }
}
int main() {
  read(n);
  read(m);
  ans0 = 1;
  for (int(i) = (1); (i) <= (n); (i)++) {
    read(cnt[i]);
    for (int(j) = (0); (j) < (cnt[i]); (j)++) {
      read(a[i][j]);
      int x = a[i][j];
      if (x > 0)
        toti[x] += i, totj[x] += j;
      else
        toti[-x] += i, totj[-x] += j;
      used[abs(a[i][j])]++;
    }
  }
  memset(q, -1, sizeof q);
  for (int(i) = (1); (i) <= (n); (i)++)
    if (!vis[i]) {
      if ((cnt[i] == 2) && (abs(a[i][0]) == abs(a[i][1]))) {
        if (a[i][0] == a[i][1]) {
          int nans0 = add(ans0, ans1), nans1 = add(ans0, ans1);
          ans0 = nans0;
          ans1 = nans1;
        } else {
          int nans0 = add(ans1, ans1), nans1 = add(ans0, ans0);
          ans0 = nans0;
          ans1 = nans1;
        }
        vis[i] = 1;
        continue;
      }
    }
  for (int(i) = (1); (i) <= (n); (i)++)
    if (!vis[i]) {
      for (int(j) = (1); (j) <= (sz); (j)++) q[j][0] = q[j][1] = -1;
      sz = 0;
      cir = 0;
      if (cnt[i] == 1) {
        dfs(i, 0);
        DP();
      } else {
        if (used[abs(a[i][0])] == 1) {
          dfs(i, 0);
          DP();
        } else if (used[abs(a[i][1])] == 1) {
          dfs(i, 1);
          DP();
        }
      }
    }
  for (int(i) = (1); (i) <= (n); (i)++)
    if (!vis[i]) {
      for (int(j) = (1); (j) <= (sz); (j)++) q[j][0] = q[j][1] = -1;
      sz = 0;
      cir = 0;
      dfs(i, 0);
      DP();
    }
  for (int(i) = (1); (i) <= (m); (i)++)
    if (!used[i]) ans1 = add(ans1, ans1);
  printf("%d\n", ans1);
  return 0;
}
