#include <bits/stdc++.h>
using namespace std;
int n, m, tot, neg;
int head[110000], nex[110000 << 1], to[110000 << 1], val[110000 << 1];
int vis[110000], cnt[110000], a[110000], b[110000], use[110000],
    u1[110000 << 1];
int st[110000][2], top, ans, du[110000], f[110000][2][2], g[110000][2][2][2],
    d[110000][2];
int e[110000], sum;
void add(int x, int y, int z) {
  tot++;
  nex[tot] = head[x];
  head[x] = tot;
  to[tot] = y;
  val[tot] = z;
}
void dfs(int x) {
  if (use[x]) return;
  use[x] = 1;
  for (int i = head[x]; i; i = nex[i])
    if (!u1[i]) {
      e[++sum] = i;
      u1[i] = u1[i ^ 1] = 1;
      dfs(to[i]);
    }
}
int get(int v, int x, int y) {
  if (to[v] != abs(b[val[v]])) swap(x, y);
  int t = val[v];
  if (a[t] < 0) x ^= 1;
  if (b[t] < 0) y ^= 1;
  return x | y;
}
int main() {
  scanf("%d%d", &n, &m);
  tot = 1;
  int ans = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &cnt[i]);
    if (cnt[i] == 1) {
      scanf("%d", &a[i]);
      if (vis[abs(a[i])]) {
        st[top][0] = st[top][1] = 0;
        top--;
        (ans *= 2) %= 1000000007;
        continue;
      }
      vis[abs(a[i])] = a[i];
      if (!du[abs(a[i])]) st[++top][0] = st[top][1] = 1;
    }
    if (cnt[i] == 2) {
      scanf("%d%d", &a[i], &b[i]);
      if (a[i] == -b[i]) {
        neg++, vis[abs(a[i])] = 1;
        (ans *= 2) %= 1000000007;
      } else {
        int a1 = abs(a[i]), b1 = abs(b[i]);
        if (a1 == b1)
          vis[a1] = 1, st[++top][0] = st[top][1] = 1;
        else {
          add(a1, b1, i);
          add(b1, a1, i);
          du[a1]++;
          du[b1]++;
          if (vis[a1]) st[top][0] = st[top][1] = 0, top--;
          if (vis[b1]) st[top][0] = st[top][1] = 0, top--;
        }
      }
    }
  }
  for (int now = 1; now <= m; now++)
    if (!use[now] && du[now] != 2) {
      if (!du[now] && !vis[now])
        (ans *= 2) %= 1000000007;
      else if (!du[now])
        continue;
      else {
        sum = 0;
        dfs(now);
        for (int i = 1; i <= sum; i++) memset(f[i], 0, sizeof(f[i]));
        if (vis[now]) {
          if (vis[now] < 0) {
            f[1][0][get(e[1], 0, 0) ^ 1]++;
            f[1][1][get(e[1], 0, 1) ^ 1]++;
            f[1][0][get(e[1], 1, 0)]++;
            f[1][1][get(e[1], 1, 1)]++;
          } else {
            f[1][0][get(e[1], 0, 0)]++;
            f[1][1][get(e[1], 0, 1)]++;
            f[1][0][get(e[1], 1, 0) ^ 1]++;
            f[1][1][get(e[1], 1, 1) ^ 1]++;
          }
        } else {
          f[1][0][get(e[1], 0, 0)]++;
          f[1][1][get(e[1], 0, 1)]++;
          f[1][0][get(e[1], 1, 0)]++;
          f[1][1][get(e[1], 1, 1)]++;
        }
        for (int i = 1; i < sum; i++)
          for (int j = 0; j <= 1; j++)
            for (int k = 0; k <= 1; k++)
              for (int t = 0; t <= 1; t++) {
                (f[i + 1][j][t ^ get(e[i + 1], k, j)] += f[i][k][t]) %=
                    1000000007;
              }
        top++;
        for (int i = 0; i <= 1; i++) {
          for (int j = 0, t; j <= 1; j++) {
            if (t = vis[to[e[sum]]])
              (st[top][j ^ i ^ (t < 0)] += f[sum][i][j]) %= 1000000007;
            else
              (st[top][j] += f[sum][i][j]) %= 1000000007;
          }
        }
      }
    }
  for (int now = 1; now <= m; now++)
    if (!use[now] && du[now] == 2) {
      sum = 0;
      dfs(now);
      for (int i = 1; i <= sum; i++) memset(g[i], 0, sizeof(g[i]));
      g[1][0][0][get(e[1], 0, 0)]++;
      g[1][0][1][get(e[1], 0, 1)]++;
      g[1][1][0][get(e[1], 1, 0)]++;
      g[1][1][1][get(e[1], 1, 1)]++;
      for (int i = 1; i < sum - 1; i++)
        for (int j = 0; j <= 1; j++)
          for (int k = 0; k <= 1; k++)
            for (int t = 0; t <= 1; t++)
              for (int w = 0; w <= 1; w++) {
                (g[i + 1][j][t][w ^ get(e[i + 1], k, t)] += g[i][j][k][w]) %=
                    1000000007;
              }
      top++;
      for (int i = 0; i <= 1; i++)
        for (int j = 0; j <= 1; j++)
          for (int k = 0; k <= 1; k++) {
            (st[top][get(e[sum], j, i) ^ k] += g[sum - 1][i][j][k]) %=
                1000000007;
          }
    }
  d[0][0] = ans;
  for (int i = 1; i <= top; i++)
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k <= 1; k++)
        (d[i][j ^ k] += (long long)d[i - 1][j] * st[i][k] % 1000000007) %=
            1000000007;
  if (neg & 1)
    printf("%d\n", d[top][0]);
  else
    printf("%d\n", d[top][1]);
  return 0;
}
