#include <bits/stdc++.h>
const int inf = 0x3f3f3f3f;
const int N = 100005;
const int P = 1000000007;
using namespace std;
int n, m;
vector<pair<int, int> > g[N], cl(N);
bool vis[N];
int al[N];
int f[N][2][2], dp[N][2];
int st;
bool cy;
bool calc(int c, int x, bool ax, int y = -1, bool ay = 0) {
  if (y == -1) {
    if (cl[c].first * cl[c].second < 0)
      return true;
    else if (cl[c].first < 0)
      return (ax ^ 1);
    else
      return ax;
  }
  if (x == -cl[c].first) ax ^= 1;
  if (y == -cl[c].first) ay ^= 1;
  if (x == -cl[c].second) ax ^= 1;
  if (y == -cl[c].second) ay ^= 1;
  return (ax | ay);
}
void dfs(int x, int f) {
  if (vis[x]) {
    st = x;
    cy = true;
    return;
  }
  int i;
  vis[x] = true;
  for (i = 0; i < g[x].size(); i++) {
    if (g[x][i].second != f) dfs(g[x][i].first, g[x][i].second);
  }
  if (g[x].size() == 1) st = x;
}
void DP(int &j, int &pre, int en) {
  int a, b, c, k;
  for (;;) {
    for (k = 0; k < g[j].size(); k++)
      if (g[j][k].second != pre) break;
    if (k == g[j].size()) return;
    pre = g[j][k].second;
    int nj = g[j][k].first;
    if (nj == en) break;
    f[nj][0][0] = f[nj][0][1] = f[nj][1][0] = f[nj][1][1] = 0;
    for (a = 0; a <= 1; a++)
      for (b = 0; b <= 1; b++)
        for (c = 0; c <= 1; c++) {
          int t = calc(pre, nj, a, j, b) ^ c;
          f[nj][a][t] += f[j][b][c];
          if (f[nj][a][t] >= P) f[nj][a][t] -= P;
        }
    j = nj;
  }
}
int pw(int a, int b) {
  int ans = 1;
  while (b > 0) {
    if (b & 1) ans = 1LL * ans * a % P;
    a = 1LL * a * a % P;
    b >>= 1;
  }
  return ans;
}
int main() {
  scanf("%d%d", &n, &m);
  int i, j, k, a, b;
  for (i = 0; i < n; i++) {
    scanf("%d", &k);
    if (k == 1) {
      scanf("%d", &a);
      if (a > 0)
        al[a] = 1;
      else
        al[-a] = -1;
    } else {
      scanf("%d%d", &a, &b);
      cl[i] = make_pair(a, b);
      a = abs(a);
      b = abs(b);
      g[a].push_back(make_pair(b, i));
      g[b].push_back(make_pair(a, i));
    }
  }
  int cnt = 0, nn = 0, x, pre;
  for (i = 1; i <= m; i++) {
    if (!vis[i]) {
      if (g[i].size() == 0) {
        if (al[i] == 0) {
          nn++;
          continue;
        }
        dp[cnt][0] = 1;
        dp[cnt][1] = 1;
        cnt++;
        continue;
      }
      st = -1;
      cy = false;
      dfs(i, -1);
      if (cy) {
        if (g[i][0].first == i) {
          f[i][1][calc(g[i][0].second, i, 1)]++;
          f[i][0][calc(g[i][0].second, i, 0)]++;
        } else {
          for (x = 0; x <= 1; x++) {
            j = g[i][0].first;
            f[j][0][0] = f[j][0][1] = f[j][1][1] = f[j][1][0] = 0;
            f[j][0][calc(g[i][0].second, i, x, j, 0)] = 1;
            f[j][1][calc(g[i][0].second, i, x, j, 1)] = 1;
            pre = g[i][0].second;
            DP(j, pre, i);
            for (a = 0; a <= 1; a++)
              for (b = 0; b <= 1; b++) {
                int t = calc(pre, i, x, j, a);
                f[i][x][t ^ b] += f[j][a][b];
                if (f[i][x][t ^ b] >= P) f[i][x][t ^ b] -= P;
              }
          }
        }
        dp[cnt][0] = f[i][0][0] + f[i][1][0];
        if (dp[cnt][0] >= P) dp[cnt][0] -= P;
        dp[cnt][1] = f[i][0][1] + f[i][1][1];
        if (dp[cnt][1] >= P) dp[cnt][1] -= P;
        cnt++;
      } else {
        if (al[st] < 0) {
          f[st][0][1] = f[st][1][0] = 1;
        } else if (al[st] > 0) {
          f[st][0][0] = f[st][1][1] = 1;
        } else
          f[st][0][0] = f[st][1][0] = 1;
        int j = st, pre = -1;
        DP(j, pre, -1);
        if (al[j] != 0) {
          int tmp[2][2];
          for (a = 0; a <= 1; a++)
            for (b = 0; b <= 1; b++) {
              tmp[a][b] = f[j][a][b];
              f[j][a][b] = 0;
            }
          for (a = 0; a <= 1; a++)
            for (b = 0; b <= 1; b++) {
              int t = b ^ a ^ (al[j] < 0 ? 1 : 0);
              f[j][a][t] += tmp[a][b];
              if (f[j][a][t] >= P) f[j][a][b] -= P;
            }
        }
        dp[cnt][0] = f[j][0][0] + f[j][1][0];
        if (dp[cnt][0] >= P) dp[cnt][0] -= P;
        dp[cnt][1] = f[j][0][1] + f[j][1][1];
        if (dp[cnt][1] >= P) dp[cnt][1] -= P;
        cnt++;
      }
    }
  }
  for (i = 1; i < cnt; i++) {
    int t0, t1;
    t0 = 1LL * dp[i - 1][0] * dp[i][0] % P + 1LL * dp[i - 1][1] * dp[i][1] % P;
    if (t0 >= P) t0 -= P;
    t1 = 1LL * dp[i - 1][1] * dp[i][0] % P + 1LL * dp[i - 1][0] * dp[i][1] % P;
    if (t1 >= P) t1 -= P;
    dp[i][0] = t0;
    dp[i][1] = t1;
  }
  printf("%d\n", 1LL * dp[cnt - 1][1] * pw(2, nn) % P);
  return 0;
}
