#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void scf(T &x) {
  bool f = 0;
  x = 0;
  char c = getchar();
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  if (c == '-') f = 1, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
  return;
}
template <typename T1, typename T2>
inline void scf(T1 &x, T2 &y) {
  scf(x);
  scf(y);
}
template <typename T1, typename T2, typename T3>
inline void scf(T1 &x, T2 &y, T3 &z) {
  scf(x);
  scf(y);
  scf(z);
}
template <typename T1, typename T2, typename T3, typename T4>
inline void scf(T1 &x, T2 &y, T3 &z, T4 &w) {
  scf(x);
  scf(y);
  scf(z);
  scf(w);
}
template <typename T>
inline bool chkmin(T &x, const T &y) {
  return x > y ? x = y, 1 : 0;
}
template <typename T>
inline bool chkmax(T &x, const T &y) {
  return x < y ? x = y, 1 : 0;
}
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
int n, m;
int dp[2], foo[2];
int sg[maxn][2], deg[maxn];
bool vis[maxn];
bool fuck;
int pd[maxn][2][2][2];
void ADD(int &x, const int &y) { x = (x + y < mod) ? (x + y) : (x + y - mod); }
struct edge {
  edge *next;
  int to, cur, nxt;
  edge() {}
  edge(edge *N, int T, int x, int y) {
    next = N;
    to = T;
    cur = x;
    nxt = y;
  }
} * head[maxn];
void add_edge(int u, int v, int x, int y) {
  edge *e = new edge(head[u], v, x, y);
  head[u] = e;
  ++deg[u];
  return;
}
void dfs(int u) {
  vis[u] = 1;
  for (edge *e = head[u]; e; e = e->next) {
    int &v = e->to, &x = e->cur, &y = e->nxt;
    if (vis[v]) continue;
    dfs(v);
    for (int f = 0; f < (2); ++f)
      for (int xx = 0; xx < (2); ++xx)
        for (int yy = 0; yy < (2); ++yy)
          for (int x0 = 0; x0 < (2); ++x0)
            ADD(pd[u][xx][f ^ (x != xx || y != yy) ^ sg[u][xx]][x0],
                pd[v][yy][f][x0]);
  }
  if (!fuck) pd[u][0][sg[u][0]][0] = pd[u][1][sg[u][1]][1] = 1, fuck = 1;
  return;
}
int main() {
  scf(m, n);
  for (int i = (1); i <= (m); ++i) {
    int k;
    scf(k);
    if (k == 1) {
      int x;
      scf(x);
      if (x < 0)
        sg[-x][0] ^= 1;
      else
        sg[x][1] ^= 1;
    } else {
      int x1, x2, u, v;
      scf(x1, x2);
      u = (x1 > 0) ? 0 : 1;
      v = (x2 > 0) ? 0 : 1;
      add_edge(abs(x1), abs(x2), u, v);
      add_edge(abs(x2), abs(x1), v, u);
    }
  }
  dp[0] = 1;
  for (int i = (1); i <= (n); ++i)
    if (!vis[i] && deg[i] < 2) {
      fuck = 0;
      dfs(i);
      memcpy(foo, dp, sizeof dp);
      memset(dp, 0, sizeof dp);
      for (int f = 0; f < (2); ++f)
        for (int ff = 0; ff < (2); ++ff)
          for (int x = 0; x < (2); ++x)
            for (int x0 = 0; x0 < (2); ++x0)
              ADD(dp[f ^ ff], 1ll * foo[f] * pd[i][x][ff][x0] % mod);
    }
  for (int i = (1); i <= (n); ++i)
    if (!vis[i]) {
      fuck = 0;
      dfs(i);
      memcpy(foo, dp, sizeof dp);
      memset(dp, 0, sizeof dp);
      edge *e = head[i]->next;
      int &x = e->cur, &y = e->nxt;
      for (int f = 0; f < (2); ++f)
        for (int ff = 0; ff < (2); ++ff)
          for (int xx = 0; xx < (2); ++xx)
            for (int x0 = 0; x0 < (2); ++x0)
              ADD(dp[f ^ ff], 1ll * foo[f] *
                                  pd[i][xx][ff ^ (xx != x || x0 != y)][x0] %
                                  mod);
    }
  printf("%d\n", dp[1]);
  return 0;
}
