#include <bits/stdc++.h>
using namespace std;
struct edge {
  int to, p1, p2;
};
bool vis[100010];
int dp[100010][2][2][2];
vector<edge> G[100010];
const int md = 1e9 + 7;
int con[100010][2];
void add(int &x, int y) {
  x += y;
  if (x >= md) x -= md;
}
void dfs(int x) {
  vis[x] = true;
  bool f = false;
  for (int i = 0; i < G[x].size(); i++) {
    int y = G[x][i].to, p1 = G[x][i].p1, p2 = G[x][i].p2;
    if (vis[y]) continue;
    f = true;
    dfs(y);
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          for (int m = 0; m < 2; m++) {
            add(dp[x][j][l][m ^ ((p1 ^ j) | (p2 ^ k)) ^ con[x][j]],
                dp[y][k][l][m]);
          }
        }
      }
    }
  }
  if (!f) dp[x][0][0][con[x][0]] = dp[x][1][1][con[x][1]] = 1;
}
int N, M;
int ans[2], tmp[2];
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= N; i++) {
    int k;
    scanf("%d", &k);
    if (k == 1) {
      int x;
      scanf("%d", &x);
      if (x < 0)
        con[-x][0] ^= 1;
      else
        con[x][1] ^= 1;
    } else {
      int x, y;
      int p1 = 0, p2 = 0;
      scanf("%d%d", &x, &y);
      if (x < 0) x = -x, p1 = 1;
      if (y < 0) y = -y, p2 = 1;
      G[x].push_back((edge){y, p1, p2});
      G[y].push_back((edge){x, p2, p1});
    }
  }
  ans[0] = 1;
  for (int i = 1; i <= M; i++) {
    if (vis[i]) continue;
    if (G[i].size() <= 1) {
      dfs(i);
      tmp[0] = ans[0];
      tmp[1] = ans[1];
      ans[0] = ans[1] = 0;
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          for (int l = 0; l < 2; l++) {
            for (int m = 0; m < 2; m++) {
              add(ans[j ^ k], 1LL * tmp[j] * dp[i][l][m][k] % md);
            }
          }
        }
      }
    }
  }
  for (int i = 1; i <= M; i++) {
    if (vis[i]) continue;
    dfs(i);
    tmp[0] = ans[0];
    tmp[1] = ans[1];
    ans[0] = ans[1] = 0;
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        for (int l = 0; l < 2; l++) {
          for (int m = 0; m < 2; m++) {
            add(ans[j ^ k ^ ((G[i][1].p1 ^ l) | (G[i][1].p2 ^ m))],
                1LL * tmp[j] * dp[i][l][m][k] % md);
          }
        }
      }
    }
  }
  printf("%d", ans[1]);
}
