#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
const long long mod = 1e9 + 7;
struct edge {
  int to, next, val;
} e[maxn * 2];
int head[maxn], e_num, fa[maxn], sz[maxn], cnt[maxn], n, m, ind[maxn];
bool use[maxn][2];
vector<int> son[maxn];
bool vis[maxn];
int q[maxn], w[maxn];
void add_edge(int u, int v, int c) {
  e[++e_num] = (edge){v, head[u], c};
  head[u] = e_num;
}
int getf(int a) {
  if (fa[a] ^ a) return fa[a] = getf(fa[a]);
  return a;
}
pair<long long, long long> solve_lp(int a) {
  if (cnt[a] == 1) {
    int v = e[head[a]].val;
    if (v == 0) return make_pair(1, 1);
    if (v == 3) return make_pair(1, 1);
    return make_pair(0, 2);
  }
  if (cnt[a] == 2) {
    int v1 = e[head[a]].val;
    int v2 = e[e[head[a]].next].val;
    int ans[2];
    ans[0] = ans[1] = 0;
    for (int i = 0; i < 2; ++i)
      for (int j = 0; j < 2; ++j) {
        int t1, t2;
        if (v1 & 1)
          t1 = i ^ 1;
        else
          t1 = i;
        if (v1 & 2)
          t2 = j ^ 1;
        else
          t2 = j;
        int m1, m2;
        m1 = t1 | t2;
        if (v2 & 1)
          t1 = i ^ 1;
        else
          t1 = i;
        if (v2 & 2)
          t2 = j ^ 1;
        else
          t2 = j;
        m2 = t1 | t2;
        ++ans[m1 ^ m2];
      }
    return make_pair(ans[0], ans[1]);
  }
  int hh, tt;
  hh = tt = 0;
  q[tt++] = a;
  vis[a] = 1;
  while (hh < tt) {
    int x = q[hh++];
    for (int i = head[x]; i; i = e[i].next)
      if (!vis[e[i].to]) {
        w[tt] = e[i].val, q[tt++] = e[i].to, vis[e[i].to] = 1;
        break;
      }
  }
  for (int i = head[q[tt - 1]]; i; i = e[i].next)
    if (e[i].to == q[0]) w[0] = e[i].val;
  int ans[2];
  ans[0] = ans[1] = 0;
  int v[2][2];
  memset(v, 0, sizeof(v));
  v[0][0] = 1;
  for (int i = 1; i < tt; ++i) {
    int f[2][2];
    memset(f, 0, sizeof(f));
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) {
        int cur = 0;
        if (w[i] & 1)
          cur |= t1 ^ 1;
        else
          cur |= t1;
        if (w[i] & 2)
          cur |= t2 ^ 1;
        else
          cur |= t2;
        (f[t2][cur] += v[t1][0]) %= mod;
        (f[t2][cur ^ 1] += v[t1][1]) %= mod;
      }
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) v[t1][t2] = f[t1][t2];
  }
  int f[2][2];
  memset(f, 0, sizeof(f));
  for (int t1 = 0; t1 < 2; ++t1)
    for (int t2 = 0; t2 < 1; ++t2) {
      int cur = 0;
      if (w[0] & 1)
        cur |= t1 ^ 1;
      else
        cur |= t1;
      if (w[0] & 2)
        cur |= t2 ^ 1;
      else
        cur |= t2;
      (f[t2][cur] += v[t1][0]) %= mod;
      (f[t2][cur ^ 1] += v[t1][1]) %= mod;
    }
  ans[0] = f[0][0];
  ans[1] = f[0][1];
  memset(v, 0, sizeof(v));
  v[1][0] = 1;
  for (int i = 1; i < tt; ++i) {
    int f[2][2];
    memset(f, 0, sizeof(f));
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) {
        int cur = 0;
        if (w[i] & 1)
          cur |= t1 ^ 1;
        else
          cur |= t1;
        if (w[i] & 2)
          cur |= t2 ^ 1;
        else
          cur |= t2;
        (f[t2][cur] += v[t1][0]) %= mod;
        (f[t2][cur ^ 1] += v[t1][1]) %= mod;
      }
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) v[t1][t2] = f[t1][t2];
  }
  memset(f, 0, sizeof(f));
  for (int t1 = 0; t1 < 2; ++t1)
    for (int t2 = 1; t2 < 2; ++t2) {
      int cur = 0;
      if (w[0] & 1)
        cur |= t1 ^ 1;
      else
        cur |= t1;
      if (w[0] & 2)
        cur |= t2 ^ 1;
      else
        cur |= t2;
      (f[t2][cur] += v[t1][0]) %= mod;
      (f[t2][cur ^ 1] += v[t1][1]) %= mod;
    }
  (ans[0] += f[1][0]) %= mod;
  (ans[1] += f[1][1]) %= mod;
  return make_pair(ans[0], ans[1]);
}
pair<long long, long long> solve_link(int a) {
  if (cnt[a] == 1) {
    if (use[a][0] && use[a][1]) return make_pair(0, 2);
    if (!use[a][0] && !use[a][1]) return make_pair(2, 0);
    return make_pair(1, 1);
  }
  int rt;
  for (int i = 0; i < son[a].size(); ++i)
    if (ind[son[a][i]] == 1) {
      rt = son[a][i];
      break;
    }
  int hh, tt;
  hh = tt = 0;
  q[tt++] = rt;
  vis[rt] = 1;
  while (hh < tt) {
    int x = q[hh++];
    for (int i = head[x]; i; i = e[i].next)
      if (!vis[e[i].to]) w[tt] = e[i].val, q[tt++] = e[i].to, vis[e[i].to] = 1;
  }
  int v[2][2];
  memset(v, 0, sizeof(v));
  v[0][0 ^ use[q[0]][1]] = v[1][0 ^ use[q[0]][0]] = 1;
  for (int i = 1; i < tt; ++i) {
    int f[2][2];
    memset(f, 0, sizeof(f));
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) {
        int cur = 0;
        if (w[i] & 1)
          cur |= t1 ^ 1;
        else
          cur |= t1;
        if (w[i] & 2)
          cur |= t2 ^ 1;
        else
          cur |= t2;
        (f[t2][cur] += v[t1][0]) %= mod;
        (f[t2][cur ^ 1] += v[t1][1]) %= mod;
      }
    for (int t1 = 0; t1 < 2; ++t1)
      for (int t2 = 0; t2 < 2; ++t2) {
        v[t1][t2] = f[t1][t2];
      }
  }
  int ans[2];
  ans[0] = ans[1] = 0;
  (ans[use[q[tt - 1]][1]] += v[0][0]) %= mod;
  (ans[1 ^ use[q[tt - 1]][1]] += v[0][1]) %= mod;
  (ans[use[q[tt - 1]][0]] += v[1][0]) %= mod;
  (ans[1 ^ use[q[tt - 1]][0]] += v[1][1]) %= mod;
  return make_pair(ans[0], ans[1]);
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) fa[i] = i, sz[i] = 0, cnt[i] = 1;
  int k, x, y;
  for (int i = 0; i < n; ++i) {
    scanf("%d", &k);
    if (!k) continue;
    if (k == 1) {
      scanf("%d", &x);
      if (x > 0)
        use[x][0] ^= 1;
      else
        use[-x][1] ^= 1;
    } else {
      scanf("%d%d", &x, &y);
      int t1 = (x > 0 ? 0 : 1), t2 = (y > 0 ? 0 : 1);
      x = abs(x), y = abs(y);
      ++ind[x], ++ind[y];
      add_edge(x, y, t1 + t2 * 2);
      add_edge(y, x, t2 + t1 * 2);
      x = getf(x), y = getf(y);
      if (x == y)
        ++sz[x];
      else
        fa[x] = y, sz[y] += sz[x] + 1, cnt[y] += cnt[x];
    }
  }
  for (int i = 1; i <= m; ++i) son[getf(i)].push_back(i);
  long long val[2];
  val[0] = val[1] = 0;
  ++val[0];
  for (int i = 1; i <= m; ++i)
    if (fa[i] == i) {
      pair<long long, long long> tmp;
      if (cnt[i] == sz[i])
        tmp = solve_lp(i);
      else
        tmp = solve_link(i);
      long long v0, v1;
      v0 = (val[0] * tmp.first % mod + val[1] * tmp.second % mod) % mod;
      v1 = (val[0] * tmp.second % mod + val[1] * tmp.first % mod) % mod;
      val[0] = v0;
      val[1] = v1;
    }
  printf("%d\n", (int)val[1]);
  return 0;
}
