#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int C = 26;
void add(int &x, int y) {
  x += y;
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
}
int fix(int x) {
  while (x >= MOD) x -= MOD;
  while (x < 0) x += MOD;
  return x;
}
int pw(int a, int b) {
  int ret = 1;
  while (b) {
    if (b & 1) ret = 1ll * ret * a % MOD;
    b >>= 1;
    a = 1ll * a * a % MOD;
  }
  return ret;
}
int mul(int a, int b) { return (long long)a * b % MOD; }
const int MAXN = 3e5 + 10;
int n, m;
vector<int> adj[MAXN];
map<array<int, 2>, array<int, 2>> mp;
int vis[MAXN];
vector<int> vec;
void dfs(int v, int p) {
  vis[v] = 1;
  vec.push_back(v);
  for (int u : adj[v]) {
    if (!vis[u]) {
      dfs(u, v);
    }
  }
}
int lim(int v) { return v < n ? 2 : 1; }
void solve() {
  cin >> m >> n;
  int N = n;
  array<int, 2> dp = {1, 0};
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    if (k == 1) {
      int vv;
      cin >> vv;
      int v = abs(vv) - 1;
      int u = N++;
      adj[u].push_back(v);
      adj[v].push_back(u);
      mp[{u, v}] = {0, vv < 0};
      mp[{v, u}] = {vv < 0, 0};
    } else {
      int uu, vv;
      cin >> uu >> vv;
      int u = abs(uu) - 1, v = abs(vv) - 1;
      int flip_u = uu < 0, flip_v = vv < 0;
      if (u == v) {
        vis[u] = 1;
        array<int, 2> ndp = {0, 0};
        for (int x = 0; x < 2; x++) {
          int here = (x ^ flip_v) || (x ^ flip_u);
          for (int y = 0; y < 2; y++) {
            add(ndp[here ^ y], dp[y]);
          }
        }
        dp = ndp;
        continue;
      }
      if (mp.count({v, u})) {
        vis[u] = vis[v] = 1;
        adj[v].clear();
        adj[u].clear();
        array<int, 2> ndp = {0, 0};
        for (int a = 0; a < 2; a++) {
          for (int b = 0; b < 2; b++) {
            int cl1 = (a ^ mp[{v, u}][0]) || (b ^ mp[{v, u}][1]);
            int cl2 = (a ^ flip_v) || (b ^ flip_u);
            for (int x = 0; x < 2; x++) {
              add(ndp[cl1 ^ cl2 ^ x], dp[x]);
            }
          }
        }
        dp = ndp;
        continue;
      }
      adj[u].push_back(v);
      adj[v].push_back(u);
      mp[{u, v}] = {flip_u, flip_v};
      mp[{v, u}] = {flip_v, flip_u};
    }
  }
  for (int v = 0; v < N; v++) {
    assert((int)adj[v].size() <= 2);
  }
  for (int v = 0; v < N; v++) {
    if (vis[v]) continue;
    if (adj[v].empty()) {
      for (int i = 0; i < 2; i++) dp[i] = fix(dp[i] + dp[i]);
      continue;
    }
    assert((int)adj[v].size() <= 2);
    vec.clear();
    dfs(v, -1);
    for (int u : vec) {
      vis[u] = 0;
    }
    int u = vec.back();
    vec.clear();
    dfs(u, -1);
    bool cycle = 0;
    if ((int)adj[u].size() == 2) {
      cycle = 1;
    }
    int tt = vec.size();
    assert(tt >= 2);
    int ways[2][2][2] = {};
    int prv = vec[0], nxt = vec[1];
    for (int a = 0; a < lim(prv); a++) {
      for (int b = 0; b < lim(nxt); b++) {
        int flip_prv = mp[{prv, nxt}][0], flip_nxt = mp[{prv, nxt}][1];
        int cl = (a ^ flip_prv) || (b ^ flip_nxt);
        add(ways[a][b][cl], 1);
      }
    }
    for (int i = 1; i + 1 < tt; i++) {
      prv = vec[i], nxt = vec[i + 1];
      int nways[2][2][2] = {};
      for (int f = 0; f < 2; f++) {
        for (int a = 0; a < lim(prv); a++) {
          for (int b = 0; b < lim(nxt); b++) {
            int flip_prv = mp[{prv, nxt}][0], flip_nxt = mp[{prv, nxt}][1];
            int cl = (a ^ flip_prv) || (b ^ flip_nxt);
            for (int c = 0; c < 2; c++) {
              add(nways[f][b][c ^ cl], ways[f][a][c]);
            }
          }
        }
      }
      memcpy(ways, nways, sizeof(ways));
    }
    array<int, 2> d = {0, 0};
    if (!cycle) {
      for (int f = 0; f < 2; f++) {
        for (int a = 0; a < 2; a++) {
          for (int b = 0; b < 2; b++) {
            for (int c = 0; c < 2; c++) {
              add(d[b ^ c], mul(ways[f][a][b], dp[c]));
            }
          }
        }
      }
    } else {
      int a = vec[0], b = vec.back();
      assert(a != b);
      for (int first = 0; first < 2; first++) {
        for (int last = 0; last < 2; last++) {
          int flip_a = mp[{a, b}][0], flip_b = mp[{a, b}][1];
          int cl = (first ^ flip_a) || (last ^ flip_b);
          for (int here = 0; here < 2; here++) {
            for (int before = 0; before < 2; before++) {
              add(d[before ^ here ^ cl],
                  mul(ways[first][last][here], dp[before]));
            }
          }
        }
      }
    }
    dp = d;
  }
  cout << dp[1] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int te = 1;
  for (int w = 1; w <= te; w++) {
    solve();
  }
  return 0;
}
