func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 30;   class Solution;   class LinearBasis {    public:     friend class Solution;     LinearBasis() : size(0) { fill(begin(bs), end(bs), 0); }     LinearBasis& operator=(const LinearBasis& other) {       copy(begin(other.bs), end(other.bs), begin(bs));       size = other.size;       return *this;     }     void add(int num) {       for (int i = 0; i < N; ++i) {         if (num & (1 << i)) {           if (bs[i] == 0) {             bs[i] = num;             ++size;             break;           } else {             num ^= bs[i];           }         }       }     }     bool isValid(int num) {       if (num == 0) {         return true;       }       for (int i = 0; i < N; ++i) {         if (num & (1 << i)) {           num ^= bs[i];           if (num == 0) {             return true;           }         }       }       return false;     }       protected:     int bs[N];     int size;   };   class Solution {    public:     Solution(vector<int>& _A, int n) : nums(_A), size(n) { init(); }     int query(int l, int x) {       if (l <= 0) {         return 0;       }       l = min(l, size);       if (lbs[l].isValid(x)) {         return powM(2, l - lbs[l].size);       } else {         return 0;       }     }       private:     int size;     vector<int> nums;     vector<LinearBasis> lbs;     const int M = 1e9 + 7;     void init() {       lbs.clear();       lbs.resize(size + 1);       for (int i = 0; i < size; ++i) {         int a = nums[i];         lbs[i + 1] = lbs[i];         lbs[i + 1].add(a);       }     }     long long normalize(long long a) {       a %= M;       if (a < 0) {         a += M;       }       return a;     }     long long addM(long long a, long long b) { return normalize(a + b); }     long long mulM(long long a, long long b) { return normalize(a * b); }     long long powM(long long x, long long e) {       long long res = 1;       while (e > 0) {         if (e & 0x1) {           res = mulM(res, x);         }         x = mulM(x, x);         e >>= 1;       }       return res;     }   };   int main(int argc, char** argv) {     ios::sync_with_stdio(false);     cin.tie(0);     int n, q;     cin >> n >> q;     vector<int> nums(n);     for (int i = 0; i < n; ++i) {       cin >> nums[i];     }     Solution sol(nums, n);     for (int i = 0, l = 0, x = 0; i < q; ++i) {       cin >> l >> x;       cout << sol.query(l, x) << endl;     }     return 0;   }   