#include <bits/stdc++.h>
int fr[100010], ne[200010], v[200010], w[200010], bs = 0;
void addb(int a, int b, int c) {
  v[bs] = b;
  w[bs] = c;
  ne[bs] = fr[a];
  fr[a] = bs++;
}
int dl[100010], he, ta;
bool bk[100010], bd[100010];
void bfs(int S) {
  he = 0;
  ta = 1;
  dl[0] = S;
  bk[S] = true;
  while (he < ta) {
    int u = dl[he++];
    for (int i = fr[u]; i != -1; i = ne[i]) {
      if (!bk[v[i]]) bk[v[i]] = true, dl[ta++] = v[i];
    }
  }
}
int ss[100010], sz[100010], sl[100010][4], fn[4] = {0, 2, 1, 3},
                                           dp[100010][2][2], zh[100010];
int cal(int a, int b, int c) {
  if (c & 1) a ^= 1;
  if (c & 2) b ^= 1;
  return a | b;
}
void do_dp(int k, int z0 = 0) {
  for (int i = k; i >= 0; i--) {
    for (int j = 0; j < 2; j++) {
      for (int a = 0; a < 2; a++) {
        if (i == k) {
          dp[i][j][a] = (j == 0 && a == z0);
          continue;
        }
        dp[i][j][a] = 0;
        for (int b = 0; b < 2; b++) {
          int s = (ss[sz[i]] & a);
          for (int c = 0; c < 4; c++) {
            if (sl[i][c]) s ^= cal(a, b, c);
          }
          dp[i][j][a] = (dp[i][j][a] + dp[i + 1][j ^ s][b]) % 1000000007;
        }
      }
    }
  }
}
int main() {
  int n, m, hh = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) fr[i] = -1;
  for (int i = 0; i < n; i++) {
    int k, a, b, c = 0;
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d", &a);
      if (a < 0) hh ^= 1, a = -a;
      ss[a] ^= 1;
    } else {
      scanf("%d%d", &a, &b);
      if (a < 0) a = -a, c += 1;
      if (b < 0) b = -b, c += 2;
      if (a == b)
        zh[a] = (c == 0 || c == 3 ? 1 : 2);
      else
        addb(a, b, c), addb(b, a, -1);
      if (zh[a] == 2) hh ^= 1;
    }
  }
  int a0 = (hh == 0), a1 = (hh == 1);
  for (int i = 1; i <= m; i++) {
    if (bk[i]) continue;
    bfs(i);
    int st = -1, k = 0, s0, s1;
    if (ta == 1) {
      int u = dl[0];
      if (zh[u] == 1 || ss[u])
        s0 = 1, s1 = 1;
      else
        s0 = 2, s1 = 0;
    } else {
      for (int j = 0; j < ta; j++) {
        int u = dl[j], s = 0;
        for (int k = fr[u]; k != -1; k = ne[k]) {
          if (!bd[v[k]]) bd[v[k]] = true, s += 1;
        }
        for (int k = fr[u]; k != -1; k = ne[k]) bd[v[k]] = false;
        if (s == 1) st = u;
      }
      if (st != -1) {
        int u = st, la = -1;
        while (u != -1) {
          int e = -1;
          sz[k++] = u;
          for (int j = fr[u]; j != -1; j = ne[j]) {
            if (v[j] != la) {
              e = v[j];
              break;
            }
          }
          la = u;
          u = e;
        }
        sz[k] = -1;
        for (int j = 0; j < k; j++) {
          int u = sz[j];
          for (int s = fr[u]; s != -1; s = ne[s]) {
            if (v[s] == sz[j + 1] && w[s] != -1)
              sl[j][w[s]] ^= 1;
            else if (w[s] != -1)
              sl[j - 1][fn[w[s]]] ^= 1;
          }
        }
        do_dp(k);
        s0 = (dp[0][0][0] + dp[0][0][1]) % 1000000007;
        s1 = (dp[0][1][0] + dp[0][1][1]) % 1000000007;
      } else {
        int u = dl[0], la = -1;
        while (1) {
          int e = -1;
          sz[k++] = u;
          for (int j = fr[u]; j != -1; j = ne[j]) {
            if (v[j] != la) {
              e = v[j];
              break;
            }
          }
          la = u;
          u = e;
          if (u == dl[0]) break;
        }
        sz[k] = sz[0];
        for (int j = 0; j < k; j++) {
          int u = sz[j];
          for (int s = fr[u]; s != -1; s = ne[s]) {
            if (v[s] == sz[j + 1] && w[s] != -1)
              sl[j][w[s]] ^= 1;
            else if (w[s] != -1)
              sl[(j - 1 + k) % k][fn[w[s]]] ^= 1;
          }
        }
        do_dp(k, 0);
        s0 = dp[0][0][0];
        s1 = dp[0][1][0];
        do_dp(k, 1);
        s0 = (s0 + dp[0][0][1]) % 1000000007;
        s1 = (s1 + dp[0][1][1]) % 1000000007;
      }
    }
    int t = a1;
    a1 = (1ll * a0 * s1 + 1ll * a1 * s0) % 1000000007;
    a0 = (1ll * a0 * s0 + 1ll * t * s1) % 1000000007;
    for (int j = 0; j < k; j++) {
      for (int a = 0; a < 4; a++) sl[j][a] = 0;
    }
  }
  printf("%d", a1);
  return 0;
}
