#include <bits/stdc++.h>
using namespace std;
int a[200001][4], ls[100001], b[100001][2], B[100001], d[100001], D[100001],
    d2[100001], len, n, m, i, j, k, l, l1, l2, s, S, tp, x, y, tot;
long long f[100001][2][2], ans[2], Ans[2], F[2];
bool bz[100001];
void New(int x, int y, int s1, int s2) {
  ++len;
  a[len][0] = y;
  a[len][1] = ls[x];
  ls[x] = len;
  a[len][2] = s1;
  a[len][3] = s2;
}
void NEW(int x, int y, int s1, int s2) {
  New(x, y, s1, s2);
  New(y, x, s2, s1);
}
void dfs(int t) {
  int i;
  bz[t] = 1;
  D[++tot] = t;
  for (i = ls[t]; i; i = a[i][1])
    if (!bz[a[i][0]]) d2[tot] = i, dfs(a[i][0]);
}
int main() {
  scanf("%d%d", &m, &n);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &tp, &x);
    if (tp == 2)
      scanf("%d", &y),
          NEW(((x) > 0 ? (x) : -(x)), ((y) > 0 ? (y) : -(y)), x < 0, y < 0),
          ++d[((x) > 0 ? (x) : -(x))], ++d[((y) > 0 ? (y) : -(y))];
    else
      b[((x) > 0 ? (x) : -(x))][++B[((x) > 0 ? (x) : -(x))]] = x < 0;
  }
  ans[0] = 1;
  for (i = 1; i <= n; i++)
    if (!d[i]) {
      Ans[0] = Ans[1] = 0;
      bz[i] = 1;
      for (j = 0; j <= 1; j++) {
        s = 0;
        for (l = 1; l <= B[i]; l++) s ^= j ^ b[i][l];
        Ans[0] = ((Ans[0]) + (ans[0 ^ s])) % 1000000007;
        Ans[1] = ((Ans[1]) + (ans[1 ^ s])) % 1000000007;
      }
      ans[0] = Ans[0], ans[1] = Ans[1];
    }
  for (i = 1; i <= n; i++)
    if (!bz[i] && d[i] == 1) {
      Ans[0] = Ans[1] = 0;
      tot = 0;
      dfs(i);
      for (j = 0; j <= 1; j++) {
        for (k = 1; k <= tot; k++) memset(f[D[k]], 0, sizeof(f[D[k]]));
        f[D[1]][0][0] = f[D[1]][1][0] = 0;
        s = 0;
        for (l = 1; l <= B[D[1]]; l++) s ^= j ^ b[D[1]][l];
        f[D[1]][j][s] = 1;
        for (k = 1; k <= tot - 1; k++) {
          for (l1 = 0; l1 <= 1; l1++) {
            for (l2 = 0; l2 <= 1; l2++) {
              for (x = 0; x <= 1; x++) {
                s = l2 ^ ((l1 ^ a[d2[k]][2]) | (x ^ a[d2[k]][3]));
                for (l = 1; l <= B[D[k + 1]]; l++) s ^= x ^ b[D[k + 1]][l];
                f[D[k + 1]][x][s] =
                    ((f[D[k + 1]][x][s]) + (f[D[k]][l1][l2])) % 1000000007;
              }
            }
          }
        }
        Ans[0] = ((Ans[0]) + (ans[0] * (f[D[tot]][0][0] + f[D[tot]][1][0]) +
                              ans[1] * (f[D[tot]][0][1] + f[D[tot]][1][1]))) %
                 1000000007;
        Ans[1] = ((Ans[1]) + (ans[0] * (f[D[tot]][0][1] + f[D[tot]][1][1]) +
                              ans[1] * (f[D[tot]][0][0] + f[D[tot]][1][0]))) %
                 1000000007;
      }
      ans[0] = Ans[0], ans[1] = Ans[1];
    }
  for (i = 1; i <= n; i++)
    if (!bz[i] && d[i] == 2) {
      Ans[0] = Ans[1] = 0;
      tot = 0;
      dfs(i);
      for (j = ls[D[tot]]; j; j = a[j][1])
        if (a[j][0] == D[1] && (j + 1) / 2 != (d2[1] + 1) / 2) {
          d2[tot] = j;
          break;
        }
      for (j = 0; j <= 1; j++) {
        for (k = 1; k <= tot; k++) memset(f[D[k]], 0, sizeof(f[D[k]]));
        f[D[1]][0][0] = f[D[1]][1][0] = 0;
        s = 0;
        for (l = 1; l <= B[D[1]]; l++) s ^= j ^ b[D[1]][l];
        f[D[1]][j][s] = 1;
        for (k = 1; k <= tot - 1; k++) {
          for (l1 = 0; l1 <= 1; l1++) {
            for (l2 = 0; l2 <= 1; l2++) {
              for (x = 0; x <= 1; x++) {
                s = l2 ^ ((l1 ^ a[d2[k]][2]) | (x ^ a[d2[k]][3]));
                for (l = 1; l <= B[D[k + 1]]; l++) s ^= x ^ b[D[k + 1]][l];
                f[D[k + 1]][x][s] =
                    ((f[D[k + 1]][x][s]) + (f[D[k]][l1][l2])) % 1000000007;
              }
            }
          }
        }
        memset(F, 0, sizeof(F));
        for (l1 = 0; l1 <= 1; l1++) {
          for (l2 = 0; l2 <= 1; l2++) {
            s = l2 ^ ((l1 ^ a[d2[tot]][2]) | (j ^ a[d2[tot]][3]));
            F[s] = ((F[s]) + (f[D[tot]][l1][l2])) % 1000000007;
          }
        }
        Ans[0] = ((Ans[0]) + (ans[0] * F[0] + ans[1] * F[1])) % 1000000007;
        Ans[1] = ((Ans[1]) + (ans[0] * F[1] + ans[1] * F[0])) % 1000000007;
      }
      ans[0] = Ans[0], ans[1] = Ans[1];
    }
  printf("%I64d\n", ans[1]);
  return 0;
}
