#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
struct edge_t {
  int next;
  int mysign;
  int opsign;
  int edge_index;
};
int n, m;
vector<vector<edge_t>> graph;
vector<int> visit;
vector<int> singleterm;
vector<bool> visit_edge;
pair<long long, long long> countChain(int s) {
  int dp[2][2] = {0, 0, 0, 0};
  visit[s] = 1;
  if (singleterm[s] == 0) {
    dp[0][0] = 1;
    dp[1][0] = 1;
  } else if (singleterm[s] == 1) {
    dp[0][0] = 1;
    dp[1][1] = 1;
  } else if (singleterm[s] == -1) {
    dp[0][1] = 1;
    dp[1][0] = 1;
  }
  int prev = -1, cur = s;
  for (;;) {
    bool found = false;
    for (const auto &edge : graph[cur]) {
      if (visit_edge[edge.edge_index]) continue;
      if (edge.next == prev) continue;
      visit_edge[edge.edge_index] = true;
      found = true;
      prev = cur;
      cur = edge.next;
      long long ndp[2][2] = {0, 0, 0, 0};
      for (int pval = 0; pval < 2; pval++) {
        for (int ptotal = 0; ptotal < 2; ptotal++) {
          for (int cval = 0; cval < 2; cval++) {
            int edge_value = (pval ^ edge.mysign) | (cval ^ edge.opsign);
            int vert_value = 0;
            if (singleterm[cur] == 1 && cval) vert_value = 1;
            if (singleterm[cur] == -1 && cval == 0) vert_value = 1;
            ndp[cval][ptotal ^ edge_value ^ vert_value] += dp[pval][ptotal];
          }
        }
      }
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++) dp[i][j] = ndp[i][j] % mod;
      visit[cur] = true;
      break;
    }
    if (!found) break;
  }
  long long ans0 = (dp[0][0] + dp[1][0]) % mod;
  long long ans1 = (dp[0][1] + dp[1][1]) % mod;
  return make_pair(ans0, ans1);
}
pair<long long, long long> countCycle(int s) {
  long long ans0 = 0;
  long long ans1 = 0;
  vector<int> vertexlist;
  vector<edge_t> vedges;
  {
    int prev = -1, cur = s;
    for (;;) {
      vertexlist.push_back(cur);
      visit[cur] = 1;
      for (const auto &edge : graph[cur]) {
        if (visit_edge[edge.edge_index]) continue;
        visit_edge[edge.edge_index] = true;
        vedges.push_back(edge);
        prev = cur;
        cur = edge.next;
        break;
      }
      if (cur == s) break;
    }
  }
  for (int initvalue = 0; initvalue < 2; initvalue++) {
    int dp[2][2] = {0, 0, 0, 0};
    if (singleterm[s] == 0) {
      if (initvalue == 0) dp[0][0] = 1;
      if (initvalue == 1) dp[1][0] = 1;
    } else if (singleterm[s] == 1) {
      if (initvalue == 0) dp[0][0] = 1;
      if (initvalue == 1) dp[1][1] = 1;
    } else if (singleterm[s] == -1) {
      if (initvalue == 0) dp[0][1] = 1;
      if (initvalue == 1) dp[1][0] = 1;
    }
    for (int vv = 0; vv < vertexlist.size(); vv++) {
      int prev = vertexlist[vv];
      int next = vertexlist[(vv + 1) % vertexlist.size()];
      const auto &edge = vedges[vv];
      long long ndp[2][2] = {0, 0, 0, 0};
      for (int pval = 0; pval < 2; pval++) {
        for (int ptotal = 0; ptotal < 2; ptotal++) {
          for (int cval = 0; cval < 2; cval++) {
            int edge_value = (pval ^ edge.mysign) | (cval ^ edge.opsign);
            int vert_value = 0;
            if (singleterm[next] == 1 && cval) vert_value = 1;
            if (singleterm[next] == -1 && cval == 0) vert_value = 1;
            ndp[cval][ptotal ^ edge_value ^ vert_value] += dp[pval][ptotal];
          }
        }
      }
      for (int i = 0; i < 2; i++)
        for (int j = 0; j < 2; j++) dp[i][j] = ndp[i][j] % mod;
    }
    ans0 += dp[initvalue][0];
    ans1 += dp[initvalue][1];
  }
  ans0 %= mod;
  ans1 %= mod;
  return make_pair(ans0, ans1);
}
int main() {
  scanf("%d%d", &n, &m);
  visit.resize(m);
  singleterm.resize(m);
  graph.resize(m);
  int destsign = 1;
  for (int i = 0; i < n; i++) {
    int cnt;
    scanf("%d", &cnt);
    if (cnt == 1) {
      int a;
      scanf("%d", &a);
      int ra = abs(a) - 1;
      if (a < 0) {
        if (singleterm[ra] == 0) {
          singleterm[ra] = -1;
        } else if (singleterm[ra] == 1) {
          singleterm[ra] = 0;
          destsign ^= 1;
        } else if (singleterm[ra] == -1) {
          singleterm[ra] = 0;
        }
      } else {
        if (singleterm[ra] == 0) {
          singleterm[ra] = 1;
        } else if (singleterm[ra] == 1) {
          singleterm[ra] = 0;
        } else if (singleterm[ra] == -1) {
          singleterm[ra] = 0;
          destsign ^= 1;
        }
      }
    } else {
      int a, b;
      scanf("%d%d", &a, &b);
      int ra = abs(a) - 1, rb = abs(b) - 1;
      if (ra == rb) {
        if (a != b) {
          destsign ^= 1;
        } else {
          if (a < 0)
            singleterm[ra] = -1;
          else
            singleterm[ra] = 1;
        }
      } else {
        {
          edge_t forward;
          forward.next = rb;
          forward.mysign = (a < 0);
          forward.opsign = (b < 0);
          forward.edge_index = i;
          graph[ra].push_back(forward);
        }
        {
          edge_t backward;
          backward.next = ra;
          backward.mysign = (b < 0);
          backward.opsign = (a < 0);
          backward.edge_index = i;
          graph[rb].push_back(backward);
        }
      }
    }
  }
  visit_edge.resize(n);
  long long dp[2] = {1, 0};
  for (int i = 0; i < m; i++) {
    if (graph[i].size() <= 1 && visit[i] == 0) {
      auto sub = countChain(i);
      long long mul[2] = {sub.first, sub.second};
      long long ndp[2] = {0, 0};
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          ndp[j ^ k] += mul[j] * dp[k];
          ndp[j ^ k] %= mod;
        }
      }
      dp[0] = ndp[0];
      dp[1] = ndp[1];
    }
  }
  for (int i = 0; i < m; i++) {
    if (visit[i] == 0) {
      auto sub = countCycle(i);
      long long mul[2] = {sub.first, sub.second};
      long long ndp[2] = {0, 0};
      for (int j = 0; j < 2; j++) {
        for (int k = 0; k < 2; k++) {
          ndp[j ^ k] += mul[j] * dp[k];
          ndp[j ^ k] %= mod;
        }
      }
      dp[0] = ndp[0];
      dp[1] = ndp[1];
    }
  }
  long long ans = dp[destsign];
  ans %= mod;
  ans += mod;
  ans %= mod;
  printf("%lld\n", ans);
  return 0;
}
