#include <bits/stdc++.h>
using namespace std;
const int N = 200200, P = 1e9 + 7;
int m, n, K, x, y, u, v, t, fl = 1;
int hd[N], vi[N], W[2][N], p[N], F[2], G[2], H[2], f[2][2][N], va[N], du[N];
vector<int> ve[N];
struct edge {
  int n, v, w;
} e[N << 1];
void add(int u, int v, int w) {
  e[++fl] = (edge){hd[u], v, w};
  hd[u] = fl;
}
void dfs(int u, int f) {
  vi[u] = 1;
  p[++t] = u;
  for (int i = hd[u], v, w; v = e[i].v, w = e[i].w, i; i = e[i].n)
    if ((i ^ f) > 1) {
      va[t] = w;
      if (!vi[v]) return dfs(v, i);
    }
}
void chk(int& x) {
  x -= P;
  x += (x >> 31) & P;
}
bool ok(int x, int y, int z) { return ((x | (y << 1)) ^ z) < 3; }
void work(int u, int o) {
  t = 0;
  dfs(u, 0);
  H[0] = H[1] = 0;
  for (int J = 0; J <= 1; J++) {
    f[J][W[J][u]][1] = 1;
    for (int i = 2; i <= t; i++)
      for (int j = 0; j <= 1; j++)
        for (int k = 0; k <= 1; k++)
          for (int l = 0; l <= 1; l++)
            chk(f[l][k ^ W[l][p[i]] ^ ok(j, l, va[i - 1])][i] +=
                f[j][k][i - 1]);
    for (int j = 0; j <= 1; j++)
      if (o && ok(j, J, va[t])) swap(f[j][0][t], f[j][1][t]);
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k <= 1; k++) chk(H[k] += f[j][k][t]);
    for (int i = 1; i <= t; i++)
      for (int j = 0; j <= 1; j++)
        for (int k = 0; k <= 1; k++) f[j][k][i] = 0;
  }
  G[0] = G[1] = 0;
  for (int j = 0; j <= 1; j++)
    for (int k = 0; k <= 1; k++) chk(G[j ^ k] += 1ll * F[j] * H[k] % P);
  for (int j = 0; j <= 1; j++) F[j] = G[j];
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &K, &x);
    if (K == 2) scanf("%d", &y);
    u = x > 0;
    x = ((x) < 0 ? -(x) : (x));
    v = y > 0;
    y = ((y) < 0 ? -(y) : (y));
    if (x == y && u != v)
      W[0][x] = W[1][x] = 1;
    else if (K == 1 || x == y)
      W[u][x] ^= 1;
    else {
      du[x]++;
      add(x, y, u | v << 1);
      du[y]++;
      add(y, x, v | u << 1);
    }
  }
  for (int i = 1; i <= n; i++)
    for (int u : ve[i]) W[u][i] ^= 1;
  F[0] = 1;
  for (int i = 1; i <= n; i++)
    if (du[i] < 2 && !vi[i]) work(i, 0);
  for (int i = 1; i <= n; i++)
    if (!vi[i]) work(i, 1);
  cout << F[1] << '\n';
}
