func_code_string: #include <bits/stdc++.h>   using namespace std;   long n, m;   vector<long> clauses[100000 + 1];   vector<long> variables[100000 + 1];   long long ans[2] = {0};   bool check_clauses[100000 + 1] = {false};   long long dp_path[100000 + 1][2][2];   long long dp_cycle[100000 + 1][2][2][2];   void path_component(long start_clause) {     long cur_clause = 0, nxt_clause = 0, variable = 0;     long long temp[2];     if (clauses[start_clause].size() == 1) {       variable = abs(clauses[start_clause][0]);       if (variables[variable].size() == 1) {         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[1] = 1;           ans[0] = 1;         } else {           temp[1] = (ans[1] + ans[0]) % 1000000007;           temp[0] = (ans[1] + ans[0]) % 1000000007;           ans[1] = temp[1];           ans[0] = temp[0];         }         return;       }       nxt_clause = (abs(variables[variable][0]) != start_clause)                        ? abs(variables[variable][0])                        : abs(variables[variable][1]);       if ((long long)variables[variable][0] * (long long)variables[variable][1] >           0) {         dp_path[nxt_clause][1][1] = 0;         dp_path[nxt_clause][1][0] = 1;         dp_path[nxt_clause][0][1] = 0;         dp_path[nxt_clause][0][0] = 1;       } else {         dp_path[nxt_clause][1][1] = 1;         dp_path[nxt_clause][1][0] = 0;         dp_path[nxt_clause][0][1] = 1;         dp_path[nxt_clause][0][0] = 0;       }       cur_clause = nxt_clause;     } else {       if ((variables[abs(clauses[start_clause][0])].size() == 2) &&           (variables[abs(clauses[start_clause][1])].size() == 2))         return;       variable = (variables[abs(clauses[start_clause][0])].size() == 1)                      ? abs(clauses[start_clause][0])                      : abs(clauses[start_clause][1]);       cur_clause = start_clause;       dp_path[start_clause][1][1] = 1;       dp_path[start_clause][1][0] = 0;       dp_path[start_clause][0][1] = 0;       dp_path[start_clause][0][0] = 1;     }     if (check_clauses[start_clause]) return;     check_clauses[start_clause] = true;     check_clauses[cur_clause] = true;     while (true) {       if (clauses[cur_clause].size() == 1) {         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[0] = (dp_path[cur_clause][0][0] + dp_path[cur_clause][1][0]) %                    1000000007;           ans[1] = (dp_path[cur_clause][0][1] + dp_path[cur_clause][1][1]) %                    1000000007;         } else {           temp[0] = ((ans[1] *                       ((dp_path[cur_clause][0][1] + dp_path[cur_clause][1][1]) %                        1000000007)) %                          1000000007 +                      (ans[0] *                       ((dp_path[cur_clause][0][0] + dp_path[cur_clause][1][0]) %                        1000000007)) %                          1000000007) %                     1000000007;           temp[1] = ((ans[1] *                       ((dp_path[cur_clause][0][0] + dp_path[cur_clause][1][0]) %                        1000000007)) %                          1000000007 +                      (ans[0] *                       ((dp_path[cur_clause][0][1] + dp_path[cur_clause][1][1]) %                        1000000007)) %                          1000000007) %                     1000000007;           ans[0] = temp[0];           ans[1] = temp[1];         }         return;       }       variable = (abs(clauses[cur_clause][0]) != variable)                      ? abs(clauses[cur_clause][0])                      : abs(clauses[cur_clause][1]);       if (variables[variable].size() == 1) {         long long dp_temp[2][2];         dp_temp[0][1] = dp_path[cur_clause][0][1];         dp_temp[0][0] = dp_path[cur_clause][0][0];         dp_temp[1][1] =             (dp_path[cur_clause][0][0] + 2 * dp_path[cur_clause][1][1]) %             1000000007;         dp_temp[1][0] =             (dp_path[cur_clause][0][1] + 2 * dp_path[cur_clause][1][0]) %             1000000007;         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[0] = (dp_temp[0][0] + dp_temp[1][0]) % 1000000007;           ans[1] = (dp_temp[0][1] + dp_temp[1][1]) % 1000000007;         } else {           temp[0] = ((ans[1] * ((dp_temp[0][1] + dp_temp[1][1]) % 1000000007)) %                          1000000007 +                      (ans[0] * ((dp_temp[0][0] + dp_temp[1][0]) % 1000000007)) %                          1000000007) %                     1000000007;           temp[1] = ((ans[1] * ((dp_temp[0][0] + dp_temp[1][0]) % 1000000007)) %                          1000000007 +                      (ans[0] * ((dp_temp[0][1] + dp_temp[1][1]) % 1000000007)) %                          1000000007) %                     1000000007;           ans[0] = temp[0];           ans[1] = temp[1];         }         return;       }       nxt_clause = (abs(variables[variable][0]) != cur_clause)                        ? abs(variables[variable][0])                        : abs(variables[variable][1]);       check_clauses[nxt_clause] = true;       if ((long long)variables[variable][0] * (long long)variables[variable][1] >           0) {         dp_path[nxt_clause][0][1] =             (dp_path[cur_clause][1][1] + dp_path[cur_clause][0][1]) % 1000000007;         dp_path[nxt_clause][0][0] =             (dp_path[cur_clause][1][0] + dp_path[cur_clause][0][0]) % 1000000007;         dp_path[nxt_clause][1][1] =             (dp_path[cur_clause][1][0] + dp_path[cur_clause][0][1]) % 1000000007;         dp_path[nxt_clause][1][0] =             (dp_path[cur_clause][1][1] + dp_path[cur_clause][0][0]) % 1000000007;       } else {         dp_path[nxt_clause][1][1] =             (dp_path[cur_clause][1][0] + dp_path[cur_clause][0][0]) % 1000000007;         dp_path[nxt_clause][1][0] =             (dp_path[cur_clause][1][1] + dp_path[cur_clause][0][1]) % 1000000007;         dp_path[nxt_clause][0][1] =             (dp_path[cur_clause][1][1] + dp_path[cur_clause][0][0]) % 1000000007;         dp_path[nxt_clause][0][0] =             (dp_path[cur_clause][1][0] + dp_path[cur_clause][0][1]) % 1000000007;       }       cur_clause = nxt_clause;     }   }   void cycle_component(long start_clause) {     long cur_clause = 0, nxt_clause = 0, variable = 0;     long long temp[2];     if (clauses[start_clause].size() == 1) return;     if ((variables[abs(clauses[start_clause][0])].size() == 1) ||         (variables[abs(clauses[start_clause][1])].size() == 1))       return;     if (check_clauses[start_clause]) return;     check_clauses[start_clause] = true;     variable = abs(clauses[start_clause][0]);     nxt_clause = (abs(variables[variable][0]) != start_clause)                      ? abs(variables[variable][0])                      : abs(variables[variable][1]);     if (nxt_clause == start_clause) {       if ((long long)variables[variable][0] * (long long)variables[variable][1] >           0) {         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[1] = 1;           ans[0] = 1;         } else {           temp[1] = (ans[1] + ans[0]) % 1000000007;           temp[0] = (ans[1] + ans[0]) % 1000000007;           ans[1] = temp[1];           ans[0] = temp[0];         }       } else {         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[1] = 2;           ans[0] = 0;         } else {           temp[1] = 2 * ans[0];           temp[0] = 2 * ans[1];           ans[1] = temp[1];           ans[0] = temp[0];         }       }       return;     }     if ((long long)variables[variable][0] * (long long)variables[variable][1] >         0) {       dp_cycle[nxt_clause][1][1][1] = 0;       dp_cycle[nxt_clause][1][1][0] = 1;       dp_cycle[nxt_clause][1][0][1] = 0;       dp_cycle[nxt_clause][1][0][0] = 0;       dp_cycle[nxt_clause][0][1][1] = 0;       dp_cycle[nxt_clause][0][1][0] = 0;       dp_cycle[nxt_clause][0][0][1] = 0;       dp_cycle[nxt_clause][0][0][0] = 1;     } else {       dp_cycle[nxt_clause][1][1][1] = 0;       dp_cycle[nxt_clause][1][1][0] = 0;       dp_cycle[nxt_clause][1][0][1] = 1;       dp_cycle[nxt_clause][1][0][0] = 0;       dp_cycle[nxt_clause][0][1][1] = 1;       dp_cycle[nxt_clause][0][1][0] = 0;       dp_cycle[nxt_clause][0][0][1] = 0;       dp_cycle[nxt_clause][0][0][0] = 0;     }     cur_clause = nxt_clause;     while (true) {       check_clauses[cur_clause] = true;       variable = (abs(clauses[cur_clause][0]) != variable)                      ? abs(clauses[cur_clause][0])                      : abs(clauses[cur_clause][1]);       nxt_clause = (abs(variables[variable][0]) != cur_clause)                        ? abs(variables[variable][0])                        : abs(variables[variable][1]);       if (nxt_clause == start_clause) {         long long dp_temp[2][2];         if ((long long)variables[variable][0] *                 (long long)variables[variable][1] >             0) {           dp_temp[0][1] =               (dp_cycle[cur_clause][1][1][1] + dp_cycle[cur_clause][1][0][1] +                dp_cycle[cur_clause][0][1][1] + dp_cycle[cur_clause][0][0][1]) %               1000000007;           dp_temp[0][0] =               (dp_cycle[cur_clause][1][1][0] + dp_cycle[cur_clause][1][0][0] +                dp_cycle[cur_clause][0][1][0] + dp_cycle[cur_clause][0][0][0]) %               1000000007;           dp_temp[1][1] =               (dp_cycle[cur_clause][1][1][1] + dp_cycle[cur_clause][1][0][0] +                dp_cycle[cur_clause][0][1][0] + dp_cycle[cur_clause][0][0][1]) %               1000000007;           dp_temp[1][0] =               (dp_cycle[cur_clause][1][1][0] + dp_cycle[cur_clause][1][0][1] +                dp_cycle[cur_clause][0][1][1] + dp_cycle[cur_clause][0][0][0]) %               1000000007;         } else {           dp_temp[1][1] =               (dp_cycle[cur_clause][1][1][1] + dp_cycle[cur_clause][1][0][0] +                dp_cycle[cur_clause][0][1][1] + dp_cycle[cur_clause][0][0][0]) %               1000000007;           dp_temp[1][0] =               (dp_cycle[cur_clause][1][1][0] + dp_cycle[cur_clause][1][0][1] +                dp_cycle[cur_clause][0][1][0] + dp_cycle[cur_clause][0][0][1]) %               1000000007;           dp_temp[0][1] =               (dp_cycle[cur_clause][1][1][1] + dp_cycle[cur_clause][1][0][1] +                dp_cycle[cur_clause][0][1][0] + dp_cycle[cur_clause][0][0][0]) %               1000000007;           dp_temp[0][0] =               (dp_cycle[cur_clause][1][1][0] + dp_cycle[cur_clause][1][0][0] +                dp_cycle[cur_clause][0][1][1] + dp_cycle[cur_clause][0][0][1]) %               1000000007;         }         if ((ans[0] == 0) && (ans[1] == 0)) {           ans[0] = (dp_temp[0][0] + dp_temp[1][0]) % 1000000007;           ans[1] = (dp_temp[0][1] + dp_temp[1][1]) % 1000000007;         } else {           temp[0] = ((ans[1] * ((dp_temp[0][1] + dp_temp[1][1]) % 1000000007)) %                          1000000007 +                      (ans[0] * ((dp_temp[0][0] + dp_temp[1][0]) % 1000000007)) %                          1000000007) %                     1000000007;           temp[1] = ((ans[1] * ((dp_temp[0][0] + dp_temp[1][0]) % 1000000007)) %                          1000000007 +                      (ans[0] * ((dp_temp[0][1] + dp_temp[1][1]) % 1000000007)) %                          1000000007) %                     1000000007;           ans[0] = temp[0];           ans[1] = temp[1];         }         return;       }       if ((long long)variables[variable][0] * (long long)variables[variable][1] >           0) {         for (long i = 0; i <= 1; i++) {           dp_cycle[nxt_clause][i][0][1] =               (dp_cycle[cur_clause][i][0][1] + dp_cycle[cur_clause][i][1][1]) %               1000000007;           dp_cycle[nxt_clause][i][0][0] =               (dp_cycle[cur_clause][i][0][0] + dp_cycle[cur_clause][i][1][0]) %               1000000007;           dp_cycle[nxt_clause][i][1][1] =               (dp_cycle[cur_clause][i][0][1] + dp_cycle[cur_clause][i][1][0]) %               1000000007;           dp_cycle[nxt_clause][i][1][0] =               (dp_cycle[cur_clause][i][0][0] + dp_cycle[cur_clause][i][1][1]) %               1000000007;         }       } else {         for (long i = 0; i <= 1; i++) {           dp_cycle[nxt_clause][i][1][1] =               (dp_cycle[cur_clause][i][0][0] + dp_cycle[cur_clause][i][1][0]) %               1000000007;           dp_cycle[nxt_clause][i][1][0] =               (dp_cycle[cur_clause][i][0][1] + dp_cycle[cur_clause][i][1][1]) %               1000000007;           dp_cycle[nxt_clause][i][0][1] =               (dp_cycle[cur_clause][i][0][0] + dp_cycle[cur_clause][i][1][1]) %               1000000007;           dp_cycle[nxt_clause][i][0][0] =               (dp_cycle[cur_clause][i][0][1] + dp_cycle[cur_clause][i][1][0]) %               1000000007;         }       }       cur_clause = nxt_clause;     }   }   int main() {     cin >> n >> m;     for (long i = 1; i <= n; i++) {       long k;       cin >> k;       clauses[i].resize(k);       for (long j = 0; j < k; j++) {         cin >> clauses[i][j];         if (clauses[i][j] < 0)           variables[-clauses[i][j]].push_back(-i);         else           variables[clauses[i][j]].push_back(i);       }     }     for (long i = 1; i <= n; i++) {       path_component(i);     }     for (long i = 1; i <= n; i++) {       cycle_component(i);     }     for (long i = 1; i <= m; i++) {       if (variables[i].size() == 0) {         ans[0] = (ans[0] * 2) % 1000000007;         ans[1] = (ans[1] * 2) % 1000000007;       }     }     ans[0] = ans[0] % 1000000007;     ans[1] = ans[1] % 1000000007;     cout << ans[1] << endl;     return 0;   }   