For this Question: Given a <b>vertex cactus</b> with N nodes and M edges. You have to process Q queries on that graph, each query contains two nodes x and y. You have to find number of simple paths from x to y such that no node is visited twice in that path. Sir Isaac Newton himself has promised to give you chapo if you solve this. As the answer can be rather large, you should calculate it modulo 1000000007.
Note:- A connected undirected graph is called a vertex cactus, if each vertex of this graph belongs to at most one simple cycle.The first line contains two space-separated integers N and M 
Next M lines contain two integers u and v denoting there is an edge between u and v.
The next line contains a single integer Q the number of queries
Next Q lines contain the two integers x and y, nodes on which you have to answer the query.

Constraints:
1 <= N, M, K <= 150000
1 <= x, y <= N
x != y
It is guaranteed that the given graph is a vertex cactus.Print the answer to each query modulo 1000000007 in a newline.Sample Input
10 11
1 2
2 3
3 4
1 4
3 5
5 6
8 6
8 7
7 6
7 9
9 10
4
1 2
6 9
9 2
9 10

Sample Output
2
2
4
1
Explanation:
For 1-2 paths are (1, 2), (1, 4, 3, 2)
For 6-9 paths are (6, 7, 9), (6, 8, 7, 9)
For 9-2 paths are (9, 7, 6, 5, 3, 2), (9, 7, 6, 5, 3, 4, 1, 2), (9, 7, 8, 6, 5, 3, 2), (9, 7, 8, 6, 5, 3, 4, 1, 2), I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;

#define pu push_back
#define fi first
#define se second
#define mp make_pair
// #define int long long
#define pii pair<int,int>
#define mm (s+e)/2
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(int i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define sz 200000
vector<int>NEB[sz];

int vis[sz];
int neww[sz],val[sz],is[sz];
int cnt=1;
set<int> NE[sz];
int dfs(int s,int f)
{
	 vis[s]=1;
	for(auto it:NEB[s])
	{     if(it==f) continue;
		if(vis[it]==0)
		{
			val[s]+=dfs(it,s);
		}else if(neww[it]==0)
		{
			val[s]=cnt;
			neww[it]=-cnt;
			is[cnt]=1;
			cnt++;
		}
	}
   //cout<<s<<" "<<val[s]<<" "<<neww[s]<<endl;
	if(neww[s]<0)
	{
		neww[s]=val[s];
		return 0;
	}else if(val[s]==0)
	{
		neww[s]=cnt;
		cnt++;
		return 0;
	}
	neww[s]=val[s];
	return neww[s];


}

int up[sz][20];

int tin[sz],tout[sz],ht[sz];
int tim=0;
int l=20;
	int n,m;
void df(int s,int p,int h)
{
	tim++;
	//cout<<s<<endl;
	tin[s]=tim;
  up[s][0]=p;
  if(s>n) h++;
  ht[s]=h;
  for(int i=1;i<l;i++)
  {
  	up[s][i]=up[up[s][i-1]][i-1];
  	
  }
  vis[s]=1;
  for(auto it:NEB[s])
  {
  	if(it!=p)
  	{
  		df(it,s,h);
  	}
  }

	tim++;
	tout[s]=tim;

}
int isans(int u,int v)
{
	if(tin[u]<=tin[v] && tout[u]>=tout[v]) return 1;
	else return 0;
}

int lca(int u,int v)
{
	if(isans(u,v)==1) return u;
	else if(isans(v,u)==1) return v;
	for(int i=l-1;i>=0;i--)
	{
		if(isans(up[u][i],v)!=1)
		{
			u=up[u][i];
		}
	}
	return up[u][0];
}

vector<pii> X;
signed main()
{
	
	fast
		cin>>n>>m;
		for(int i=0;i<m;i++)
		{
			int a,b;
			cin>>a>>b;
			NEB[a].pu(b);
			NEB[b].pu(a);
			X.pu(mp(a,b));
		}
		dfs(1,0);
		memset(val,0,sizeof(val));
		memset(vis,0,sizeof(vis));
		// for(int i=1;i<=n;i++)
		// {
		// 	cout<<i<<" "<<" "<<neww[i]<<" "<<is[neww[i]]<<endl;
		// }
		for(int i=0;i<=n;i++)
		{
			NEB[i].resize(0);
		}
		for(int i=0;i<m;i++)
		{
			int a=X[i].fi;
			int b=X[i].se;
			int aa=neww[a];
			int bb=neww[b];
			if(aa!=bb)
			{ NEB[a].pu(b);
				NEB[b].pu(a);

			}
			
		}
		
		for(int i=1;i<=n;i++)
		{
			if(is[neww[i]]==1)
			{   int y=neww[i]+n+1;
				NEB[y].pu(i);
				NEB[i].pu(y);
			}
		}
		df(1,1,0);
		// for(int i=1;i<=n;i++)
		// { cout<<i<<"  "<<is[i]<<"  ";
		// 	for(auto it: NEB[i])
		// 	{
		// 		cout<<it<<" ";
		// 	}cout<<endl;
		// }
		int k;
		cin>>k;
		int ans[sz];
		ans[0]=1;
		int mod=1000000007;
		for(int i=1;i<=100000;i++)
		{
			ans[i]=(ans[i-1]*2LL)%mod;
		}
		while(k>0)
		{
			k--;
			int a,b;
			cin>>a>>b;
			
			if(a==b)
			{
				cout<<1<<"\n";
				
			}else 
			{
				int c=lca(a,b);
				int y=ht[a]+ht[b]-2*ht[c];
				if(c>n ) y++;
				cout<<ans[y]<<"\n";
			}
		}




	
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?