#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<iomanip>
#include<limits>
#include<unordered_set>
#include<cmath>
#include <numeric>
#include <array>
#include <complex>
using namespace std;
//long long p = 998244353;
long long p = 1000000007;
#define int long long
#define ll long long
#define vel vector<ll>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<pin,int>
#define V vector
#define Endl endl
#define veb vector<bool>
#define fcout cout << fixed << setprecision(15)
#define rev(s) reverse(s.begin(),s.end())
#define lower(h,val) (lower_bound(h.begin(),h.end(),val)-h.begin())
#define upper(h,val) (upper_bound(h.begin(),h.end(),val)-h.begin())
vel kai;
vel inv_kai;
int rui(int a, int n, int mod) {
	if (n == 0) { return 1 % mod; }
	int x = rui(a, n / 2, mod);
	x *= x; x %= mod;
	if (n % 2 == 1) { x *= a; x %= mod; }
	return x;
}
int root(int x, vel& pa) {
	if (pa[x] == -1) { return x; }
	int ans = root(pa[x], pa); pa[x] = ans;
	return ans;
}
bool mar(int x, int y, vel& pa) {
	x = root(x, pa);
	y = root(y, pa);
	if (x != y) { pa[x] = y; }
	return (x != y);
}
int gcd(int x, int y) {
	if (x < y) { return gcd(y, x); }
	if (y == 0) { return x; }
	return gcd(y, x % y);
}
int lcm(ll x, ll y) {
	x = abs(x); y = abs(y);
	return x * y / gcd(x, y);
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
void make_kai(int max_kai) {
	kai = vel(max_kai, 1);
	inv_kai = kai;
	rep(i, max_kai - 1) {
		kai[i + 1] = kai[i] * (i + 1); kai[i + 1] %= p;
		inv_kai[i + 1] = modinv(kai[i + 1], p);
	}
}
int com(int n, int r) {
	if ((n < 0) || (r < 0) || (r > n)) { return 0; }
	int ans = (kai[n] * inv_kai[r]) % p;
	return (ans * inv_kai[n - r]) % p;
}
vel uni(vel x) {
	if (x.size() == 0) { return x; }
	sor(x);
	int n = x.size();
	vel ans(1, x[0]);
	for (int j = 1; j < n; j++) {
		if (x[j - 1] != x[j]) { ans.push_back(x[j]); }
	}
	x = ans;
	return x;
}
void pr(vel& v) {
	int n = v.size();
	if (n != 0) {
		cout << v[0];
		rep(i, n - 1) {
			cout << " " << v[i + 1];
		}
		cout << endl;
	}
}
vel dijk(V<V<pin>>& way, int st, int inf) {
	int n = way.size();
	vel dist(n, inf); dist[st] = 0;
	priority_queue<pin, vector<pin>, greater<pin>> pq;
	pq.push(mkp(0, st));
	veb is_checked(n, false);
	while (!pq.empty()) {
		pin x = pq.top(); pq.pop();
		int pot = x.second;
		if (!is_checked[pot]) {
			is_checked[pot] = true;
			for (auto y : way[pot]) {
				int nex_dist = x.first + y.second;
				int nex_pot = y.first;
				if (dist[nex_pot] > nex_dist) {
					dist[nex_pot] = nex_dist;
					pq.push(mkp(nex_dist, y.first));
				}
			}
		}
	}
	return dist;
}
vel mul(vel& a, vel& b) {
	int n = a.size();
	int m = b.size();
	vel ans(n + m - 1, 0);
	rep(i, n) {
		rep(j, m) {
			ans[i + j] += a[i] * b[j];
			ans[i + j] %= p;
		}
	}
	return ans;
}
vel rui_p(vel& a, int n) {
	if (n == 0) { return { 1 }; }
	vel qans = rui_p(a, n / 2);
	qans = mul(qans, qans);
	if (n % 2 == 1) {
		qans = mul(qans, a);
	}
	return qans;
}
bool is_prime(int n) {
	if (n == 0 || n == 1) { return false; }
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) { return false; }
	}
	return true;
}
#define bs bitset<50>
void per(int& ans) {
	ans %= p;
	if (ans < 0) { ans += p; }
}
#define upperbound(v,val) upper_bound(v.begin(),v.end(),val)-v.begin()
#define lowerbound(v,val) lower_bound(v.begin(),v.end(),val)-v.begin()
#define mat V<V<pin>>
vvel disj_min(vel& v) {
	int n = v.size();
	vvel ret(22, vel(n));
	ret[0] = v;
	rep(i, 21) {
		rep(j, n) {
			int nex = j + (1 << i);
			if (nex < n) {
				ret[i + 1][j] = min(ret[i][j], ret[i][nex]);
			}
			else {
				ret[i + 1][j] = ret[i][j];
			}
		}
	}
	return ret;
}
vvel disj_max(vel& v) {
	int n = v.size();
	vvel ret(22, vel(n));
	ret[0] = v;
	rep(i, 21) {
		rep(j, n) {
			int nex = j + (1 << i);
			if (nex < n) {
				ret[i + 1][j] = max(ret[i][j], ret[i][nex]);
			}
			else {
				ret[i + 1][j] = ret[i][j];
			}
		}
	}
	return ret;
}
int find_min(vvel& dv, int l, int r) {
	int i = 21;
	while (l + (1 << i) > r) {
		i--;
	}
	return min(dv[i][l], dv[i][r - (1 << i)]);
}
int find_max(vvel& dv, int l, int r) {
	int i = 21;
	while (l + (1 << i) > r) {
		i--;
	}
	return max(dv[i][l], dv[i][r - (1 << i)]);
}
void pri(vel& v) {
	if (v.size() == 0) { return; }
	cout << v[0];
	rep(i, v.size() - 1) { cout << " " << v[i + 1]; }
	cout << endl;
	return;
}
vvel dbl(vel& v) {
	vvel ans(20, vel(v));
	int n = v.size();
	rep(i, 19) {
		rep(j, n) {
			ans[i + 1][j] = ans[i][ans[i][j]];
		}
	}
	return ans;
}
int lca(int s, int t, int diff, vvel& pa) {
	if (diff < 0) { return lca(t, s, -diff, pa); }
	rep(i, 19) {
		if ((diff & (1 << i)) != 0) {
			s = pa[i][s];
		}
	}
	for (int i = 19; i >= 0; i--) {
		if (pa[i][s] != pa[i][t]) {
			s = pa[i][s];
			t = pa[i][t];
		}
	}
	if (s != t) {
		s = pa[0][s];
	}
	return s;
}
#define d double
d dist(d x1, d y1, d x2, d y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int sz = 1024 * 1024;
vel bit(2 * sz, 0);
vel bit2(2 * sz, 0);
void add(int a, int w) {
	a += sz; bit[a] += w; bit2[a] = bit[a]; a /= 2;
	while (a != 0) {
		bit[a] += w;
		bit2[a] = max(bit2[2 * a], bit[2 * a] + max(bit2[2 * a + 1], (int)0));
		a /= 2;
	}
}
#define vveb V<veb>
signed main() {
	int t; cin >> t;
	rep(_, t) {
		int n = 0;int m=0;
		scanf("%ld", &n);
		scanf("%ld", &m);
		vel pp = { p,p + 2,11111101 };
		int sz = pp.size();
		vel a(n); vvel le(n, vel(sz+1,0));
		vvel qle(n, vel(sz,0));
		rep(i, n) { cin >> a[i]; le[i][3] = i; }
		int ba = 3242123;
		rep(i, m) {
			int u, v; cin >> u >> v; u--; v--;
			rep(j,sz) {
				int p1 = pp[j];
				le[v][j] += rui(ba, u, p1); le[v][j] %= p1;
				qle[v][j] = le[v][j];
			}
		}
		sor(le);
		sor(qle);
		int ans = 0;
		int nsum = 0;
		vel ze(sz,0);
		rep(i, n) {
			if (qle[i] != ze) {
				nsum += a[le[i][sz]];
				if (i==n-1||qle[i] != qle[i + 1]) { ans = gcd(ans, nsum); nsum = 0; }
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 5e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
vector<vector<int> >  adj;
queue<int> que;

ll A[MAXN];
int ord[MAXN];

bool cmp(int i,int j)
{
    if((int)adj[i].size()==(int)adj[j].size()){
        for(int t=0;t<adj[i].size();t++){
            if(adj[i][t]^adj[j][t]){
                return adj[i][t]<adj[j][t];
            }
        }
        return false;
    }
    else return (int)adj[i].size()<(int)adj[j].size();
}

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll res = 0;
    ll vv = 0;
    int pre;

    cin>>tc;

    while(tc--){
        cin>>n>>m;

        for(int i=1;i<=n;i++){
            cin>>A[i];
            ord[i] = i;
        }

        graph = vector<vector<int> > (n+1);
        adj = vector<vector<int> > (n+1);

        for(int i=0;i<m;i++){
            cin>>x>>y;
            graph[x].push_back(y);
        }

        for(int i=1;i<=n;i++){
            for(int j=0;j<graph[i].size();j++){
                cur = graph[i][j];
                adj[cur].push_back(i);
            }
        }

        sort(ord+1,ord+n+1,cmp);

        res = 0;
        vv = 0;
        pre = 0;

        for(int i=1;i<=n;i++){
            cur = ord[i];
            if((int)adj[cur].size()==0)continue;
            if((int)adj[cur].size()^pre){
                res = mygcd(res,vv);
                vv = A[cur];
            }
            else vv += A[cur];
            pre = adj[cur].size();
        }

        res = mygcd(res,vv);

        cout<<res<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 5e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
int cal[MAXN];

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>tc;

    ll vv = 0;
    ll res = 0;

    while(tc--){
        cin>>n>>m;

        for(int i=1;i<=n;i++){
            cin>>A[i];
            cal[i] = 0;
        }
        graph = vector<vector<int> > (n+1);

        for(int i=0;i<m;i++){
            cin>>x>>y;
            graph[x].push_back(y);
        }

        res = 0;

        for(int i=1;i<=n;i++){
            vv = 0;
            for(int j=0;j<graph[i].size();j++){
                cur = graph[i][j];
                cal[cur]++;
                vv+=A[cur];
            }
            res = mygcd(res,vv);
        }

        vv = 0;

        for(int i=1;i<=n;i++){
            if(cal[i]){
                vv+=A[cur];
            }
        }

        res = mygcd(res,vv);

        for(int i=1;i<=n;i++){
            vv = 0;
            for(int j=0;j<graph[i].size();j++){
                cur = graph[i][j];
                if(cal[cur]==1)vv+=A[cur];
            }
            res = mygcd(res,vv);
        }

        cout<<res<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 5e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

ll A[MAXN];
int cal[MAXN];

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    ll sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>tc;

    ll vv = 0;
    ll res = 0;

    while(tc--){
        cin>>n>>m;

        for(int i=1;i<=n;i++){
            cin>>A[i];
            cal[i] = 0;
        }

        graph = vector<vector<int> > (n+1);

        for(int i=0;i<m;i++){
            cin>>x>>y;
            graph[x].push_back(y);
        }

        res = 0;

        for(int i=1;i<=n;i++){
            vv = 0;
            for(int j=0;j<graph[i].size();j++){
                cur = graph[i][j];
                cal[cur]++;
                vv+=A[cur];
            }
            res = mygcd(res,vv);
        }

        vv = 0;

        for(int i=1;i<=n;i++){
            if(cal[i]){
                vv+=A[cur];
            }
        }

        res = mygcd(res,vv);

        cout<<res<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 5e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
vector<vector<int> >  adj;
queue<int> que;

ll A[MAXN];
int ord[MAXN];

bool cmp(int i,int j)
{
    if((int)adj[i].size()==(int)adj[j].size()){
        for(int t=0;t<adj[i].size();t++){
            if(adj[i][t]^adj[j][t]){
                return adj[i][t]<adj[j][t];
            }
        }
        return false;
    }
    else return (int)adj[i].size()<(int)adj[j].size();
}

bool chk(int i,int j)
{
    if((int)adj[i].size()==(int)adj[j].size()){
        for(int t=0;t<adj[i].size();t++){
            if(adj[i][t]^adj[j][t]){
                return true;
            }
        }
        return false;
    }
    else return true;
}

ll mygcd(ll a,ll b){
    return a?mygcd(b%a,a):b;
}

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll res = 0;
    ll vv = 0;
    int pre;

    cin>>tc;

    while(tc--){
        cin>>n>>m;

        for(int i=1;i<=n;i++){
            cin>>A[i];
            ord[i] = i;
        }

        graph = vector<vector<int> > (n+1);
        adj = vector<vector<int> > (n+1);

        for(int i=0;i<m;i++){
            cin>>x>>y;
            graph[x].push_back(y);
        }

        for(int i=1;i<=n;i++){
            for(int j=0;j<graph[i].size();j++){
                cur = graph[i][j];
                adj[cur].push_back(i);
            }
        }

        sort(ord+1,ord+n+1,cmp);

        res = 0;
        vv = 0;
        pre = 0;

        for(int i=1;i<=n;i++){
            cur = ord[i];
            if((int)adj[cur].size()==0)continue;
            if(chk(ord[i],ord[i-1])){
                res = mygcd(res,vv);
                vv = A[cur];

            }
            else vv+=A[cur];
        }

        res = mygcd(res,vv);

        cout<<res<<"\n";
    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ucin ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
T range(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rnd);
}

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}

int n, m, p[N];
ll c[N];
uint val[N], h[N];
int main() {
	ucin; int t; cin >> t;
	while(t --) {
		cin >> n >> m;
		for(int i = 1; i <= n; i ++) {
			cin >> c[i]; h[i] = 0; p[i] = i;
			val[i] = range<uint>(233, 1e9 + 7);
		}
		for(int i = 1; i <= m; i ++) {
			int u, v; cin >> u >> v; h[v] ^= val[u];
		}
		sort(p + 1, p + n + 1, [] (int x, int y) {
			return h[x] < h[y];
		});
		ll ans = 0, sum = 0;
		for(int i = 1; i <= n; i ++) {
			if(h[p[i]]) sum += c[p[i]];
			if(i == n || h[p[i]] != h[p[i + 1]]) {
				ans = __gcd(ans, sum); sum = 0;
			}
		}
		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ucin ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
T range(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rnd);
}

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}

int n, m, p[N], c[N];
ull val[N], h[N];
int main() {
	ucin; int t; cin >> t;
	while(t --) {
		cin >> n >> m;
		for(int i = 1; i <= n; i ++) {
			cin >> c[i]; h[i] = 0; p[i] = i;
			val[i] = range(0llu, ULLONG_MAX);
		}
		for(int i = 1; i <= m; i ++) {
			int u, v; cin >> u >> v; h[v] ^= val[u];
		}
		sort(p + 1, p + n + 1, [] (int x, int y) {
			return h[x] < h[y];
		});
		ll ans = 0, sum = 0;
		for(int i = 1; i <= n; i ++) {
			if(h[p[i]]) sum += c[p[i]];
			if(i == n || h[p[i]] != h[p[i + 1]]) {
				ans = __gcd(ans, sum); sum = 0;
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ucin ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
T range(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rnd);
}

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}

int n, m, p[N];
ll c[N];
ull val[N], h[N];
int main() {
	ucin; int t; cin >> t;
	while(t --) {
		cin >> n >> m;
		for(int i = 1; i <= n; i ++) {
			cin >> c[i]; h[i] = 0; p[i] = i;
			val[i] = range(0llu, ULLONG_MAX);
		}
		for(int i = 1; i <= m; i ++) {
			int u, v; cin >> u >> v; h[v] ^= val[u];
		}
		sort(p + 1, p + n + 1, [] (int x, int y) {
			return h[x] < h[y];
		});
		ll ans = 0, sum = 0;
		for(int i = 1; i <= n; i ++) {
			if(h[p[i]]) sum += c[p[i]];
			if(i == n || h[p[i]] != h[p[i + 1]]) {
				ans = __gcd(ans, sum); sum = 0;
			}
		}

		cout << ans << endl;
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ucin ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
typedef pair<int, int> pii;
typedef double db;
typedef long double ldb;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
template <typename T>
T range(T l, T r) {
	return uniform_int_distribution<T>(l, r)(rnd);
}

const int N = 5e5 + 10;
const int mod = 1e9 + 7;

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = (ll) a * a % mod)
		if(b & 1) ans = (ll) ans * a % mod;
	return ans;
}

int n, m, p[N];
ll c[N];
uint val[N], h[N];
int main() {
	int t; scanf("%d", &t);
	while(t --) {
		scanf("%d%d", &n, &m);
		for(int i = 1; i <= n; i ++) {
			scanf("%lld", c + i); h[i] = 0; p[i] = i;
			val[i] = range<uint>(233, 1e9 + 7);
		}
		for(int i = 1; i <= m; i ++) {
			int u, v; scanf("%d%d", &u, &v); h[v] ^= val[u];
		}
		sort(p + 1, p + n + 1, [] (int x, int y) {
			return h[x] < h[y];
		});
		ll ans = 0, sum = 0;
		for(int i = 1; i <= n; i ++) {
			if(h[p[i]]) sum += c[p[i]];
			if(i == n || h[p[i]] != h[p[i + 1]]) {
				ans = __gcd(ans, sum); sum = 0;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fori(b, e) for(int i = (b); i <= (e); ++i)
#define rfori(b, e) for(int i = (b); i >= (e); --i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int MOD[2] = {998244353, 19260817};
int BASE[2] = {131, 233};

int n, m;
ll c[500005];

map<pii, ll> M;
vector<int> G[500005];

void solve() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i)
        scanf("%lld", &c[i]);
    for(int i = 1; i <= n; ++i)
        G[i].clear();
    for(int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[v].push_back(u);
    }
    M.clear();
    for(int i = 1; i <= n; ++i) {
        if(G[i].empty())
            continue;
        sort(G[i].begin(), G[i].end());
        ll hashcode[2] = {0, 0};
        for(int j = 0; j < G[i].size(); ++j) {
            hashcode[0] = (hashcode[0] * BASE[0] + G[i][j]) % MOD[0];
            hashcode[1] = (hashcode[1] * BASE[1] + G[i][j]) % MOD[1];
        }
        M[pii(hashcode[0], hashcode[1])] += c[i];
    }
    ll gcd = 0;
    for(auto i : M)
        gcd = __gcd(gcd, i.second);
    printf("%lld\n", gcd);
}

int main() {
#ifdef LOCAL
    freopen("A.txt", "r", stdin);
#endif // LOCAL
    //init();
    int T = 1;
    scanf("%d", &T);
    for(int ti = 1; ti <= T; ++ti) {
        //printf("Case #%d: ", ti);
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fori(b, e) for(int i = (b); i <= (e); ++i)
#define rfori(b, e) for(int i = (b); i >= (e); --i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int MOD[2] = {998244353, 19260817};
int BASE[2] = {131, 233};

int n, m;
ll c[500005];

map<pii, ll> M;
vector<int> G[500005];

void solve() {
    scanf("%d%d", &n, &m);
    for(int i = 1; i <= n; ++i)
        scanf("%lld", &c[i]);
    for(int i = 1; i <= n; ++i)
        G[i].clear();
    for(int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[v].push_back(u);
    }
    M.clear();
    for(int i = 1; i <= n; ++i) {
        sort(G[i].begin(), G[i].end());
        ll hashcode[2] = {0, 0};
        for(int j = 0; j < G[i].size(); ++j) {
            hashcode[0] = (hashcode[0] * BASE[0] + G[i][j]) % MOD[0];
            hashcode[1] = (hashcode[1] * BASE[1] + G[i][j]) % MOD[1];
        }
        M[pii(hashcode[0], hashcode[1])] += c[i];
    }
    ll gcd = 0;
    for(auto i : M)
        gcd = __gcd(gcd, i.second);
    printf("%lld\n", gcd);
}

int main() {
#ifdef LOCAL
    freopen("A.txt", "r", stdin);
#endif // LOCAL
    //init();
    int T = 1;
    scanf("%d", &T);
    for(int ti = 1; ti <= T; ++ti) {
        //printf("Case #%d: ", ti);
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fori(b, e) for(int i = (b); i <= (e); ++i)
#define rfori(b, e) for(int i = (b); i >= (e); --i)
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int n;
ll a[1000005];
ll b[1000005];
vector<ll> fac;

void getFac(ll sum) {
    fac.clear();
    for(ll i = 2; i * i <= sum; ++i) {
        if(sum % i == 0) {
            fac.push_back(i);
            while(sum % i == 0)
                sum /= i;
        }
    }
    if(sum != 1)
        fac.push_back(sum);
}

ll help(ll d, ll sum) {
    for(int i = 1; i <= n; ++i)
        b[i] = (b[i - 1] + a[i]) % d;
    ll ans = 0;
    for(int i = 1; i <= n; ++i)
        ans += min(b[i], d - b[i]);
    return ans;
}

void solve() {
    scanf("%d", &n);
    ll sum = 0;
    for(int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }
    if(sum == 1) {
        puts("-1");
        return;
    }
    getFac(sum);
    ll ans = 1e18;
    for(ll &d : fac)
        ans = min(ans, help(d, sum));
    printf("%lld\n", ans);
}

int main() {
#ifdef LOCAL
    freopen("A.txt", "r", stdin);
#endif // LOCAL
    //init();
    int T = 1;
    //scanf("%d", &T);
    for(int ti = 1; ti <= T; ++ti) {
        //printf("Case #%d: ", ti);
        solve();
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 5e5 + 10;

int T, n, m, deg[N];
LL a[N], sum[N];
vector<int> V[N];
unordered_map<int, LL> MP;

LL solve(LL tot){
    LL ret = tot;
    LL tmp, tmp1;
    for(int i=1; i<=n; i++){
        tmp = tot;
        tmp1 = 0;
        MP.clear();
        for(int j=0; j<V[i].size(); j++){
            if(deg[V[i][j]] == 1){
                tmp -= a[V[i][j]];
                tmp1 += a[V[i][j]];
            }
            MP[deg[V[i][j]]]+=a[V[i][j]];
        }
        ret = __gcd(ret, tmp);
        ret = __gcd(ret, tmp1);
        for(auto &it : MP){
            ret = __gcd(ret, it.second);
        }
    }
    return ret;
}

int main(){
    int x, y;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &m);
        for(int i=1; i<=n; i++){
            scanf("%lld", a+i);
            sum[i] = 0;
            V[i].clear();
            deg[i] = 0;
        }

        while(m--){
            scanf("%d %d", &x, &y);
            sum[x] += a[y];
            V[x].pb(y);
            deg[y]++;
        }

        LL ans = 0;

        for(int i=1; i<=n; i++){
            if(deg[i] > 0){
                ans += a[i];
            }
        }

        ans = __gcd(ans, solve(ans));

        for(int i=1; i<=n; i++){
            ans = __gcd(ans, sum[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 5e5 + 10;

int T, n, m, deg[N];
LL a[N], sum[N];
vector<int> V[N];

LL solve(LL tot){
    LL ret = tot;
    LL tmp, tmp1;
    for(int i=1; i<=n; i++){
        tmp = tot;
        tmp1 = 0;
        for(int j=0; j<V[i].size(); j++){
            if(deg[V[i][j]] == 1){
                tmp -= a[V[i][j]];
                tmp1 += a[V[i][j]];
            }
        }
        ret = __gcd(ret, tmp);
        ret = __gcd(ret, tmp1);
    }
    return ret;
}

int main(){
    int x, y;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &m);
        LL ans = 0;
        for(int i=1; i<=n; i++){
            scanf("%lld", a+i);
            sum[i] = 0;
            ans += a[i];
            V[i].clear();
            deg[i] = 0;
        }

        while(m--){
            scanf("%d %d", &x, &y);
            sum[x] += a[y];
            V[x].pb(y);
            deg[y]++;
        }

        ans = __gcd(ans, solve(ans));

        for(int i=1; i<=n; i++){
            ans = __gcd(ans, sum[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 5e5 + 10;

int T, n, m, deg[N];
LL a[N], sum[N];
vector<int> V[N];
unordered_map<int, LL> MP;

LL solve(LL tot){
    LL ret = tot;
    LL tmp;
    for(int i=1; i<=n; i++){
        tmp = tot;
        MP.clear();
        for(int j=0; j<V[i].size(); j++){
            if(deg[V[i][j]] == 1){
                tmp -= a[V[i][j]];
            }
            MP[deg[V[i][j]]]+=a[V[i][j]];
        }
        ret = __gcd(ret, tmp);
        for(auto &it : MP){
            ret = __gcd(ret, it.second);
        }
    }
    return ret;
}

int main(){
    int x, y;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &m);
        for(int i=1; i<=n; i++){
            scanf("%lld", a+i);
            sum[i] = 0;
            V[i].clear();
            deg[i] = 0;
        }

        while(m--){
            scanf("%d %d", &x, &y);
            sum[x] += a[y];
            V[x].pb(y);
            deg[y]++;
        }

        LL ans = 0;

        for(int i=1; i<=n; i++){
            if(deg[i] > 0){
                ans += a[i];
            }
        }

        ans = __gcd(ans, solve(ans));

        for(int i=1; i<=n; i++){
            ans = __gcd(ans, sum[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 5e5 + 10;

int T, n, m, deg[N];
LL a[N], sum[N];
vector<int> V[N];

LL solve(LL tot){
    LL ret = tot;
    LL tmp;
    for(int i=1; i<=n; i++){
        tmp = tot;
        for(int j=0; j<V[i].size(); j++){
            if(deg[V[i][j]] == 1){
                tmp -= a[V[i][j]];
            }
        }
        ret = __gcd(ret, tmp);
    }
    return ret;
}

int main(){
    int x, y;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &m);
        LL ans = 0;
        for(int i=1; i<=n; i++){
            scanf("%lld", a+i);
            sum[i] = 0;
            ans += a[i];
            V[i].clear();
            deg[i] = 0;
        }
        while(m--){
            scanf("%d %d", &x, &y);
            sum[x] += a[y];
            V[x].pb(y);
            deg[y]++;
        }

        ans = __gcd(ans, solve(ans));

        for(int i=1; i<=n; i++){
            ans = __gcd(ans, sum[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;

#define pb push_back
#define mp make_pair

const int N = 5e5 + 10;

int T, n, m, deg[N];
LL a[N], sum[N];
vector<int> V[N];

LL solve(LL tot){
    LL ret = tot;
    LL tmp, tmp1;
    for(int i=1; i<=n; i++){
        tmp = tot;
        tmp1 = 0;
        for(int j=0; j<V[i].size(); j++){
            if(deg[V[i][j]] == 1){
                tmp -= a[V[i][j]];
            }
        }
        ret = __gcd(ret, tmp);
    }
    return ret;
}

int main(){
    int x, y;
    scanf("%d", &T);
    while(T--){
        scanf("%d %d", &n, &m);
        for(int i=1; i<=n; i++){
            scanf("%lld", a+i);
            sum[i] = 0;
            V[i].clear();
            deg[i] = 0;
        }

        while(m--){
            scanf("%d %d", &x, &y);
            sum[x] += a[y];
            V[x].pb(y);
            deg[y]++;
        }

        LL ans = 0;

        for(int i=1; i<=n; i++){
            if(deg[i] > 0){
                ans += a[i];
            }
        }

        ans = __gcd(ans, solve(ans));

        for(int i=1; i<=n; i++){
            ans = __gcd(ans, sum[i]);
        }
        printf("%lld\n", ans);
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long ll1;
typedef long double ld;
const ll MAX=5e5+5;
const double pi=atan(1)*4;
ll MOD=1e9+7;
#define pb push_back
#define se second
#define fi first
#define sb __builtin_popcount
#define maxe max_element
#define mine min_element
#ifndef ONLINE_JUDGE
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#else
#define debug(...)
#define debug2(...)
#define debug3(...)
#define debug4(...)
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fbo find_by_order
#define ook order_of_key
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define pll pair<ll,ll>
using namespace __gnu_pbds;
#define os1 tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define error 0.000000000000000001
template<class F>
int no_of_bits(F a){if(sizeof(a)==4)return 32-__builtin_clz(a);return 64-__builtin_clzll(a);}
ll add(ll a,ll b){return ((ll1)a+b)%MOD;}
ll mul(ll a,ll b){return ((ll1)a*b)%MOD;}
ll sub(ll a,ll b){return ((ll1)a-b+MOD)%MOD;}
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dt pair<pll,ll>
ll arr[MAX];
vector<ll>edges[MAX];
void solve(ll TC)
{
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>arr[i];
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    edges[a].pb(b);
  }
  ll sum=0;
  ll ans=0;
  set<ll>s;
  for(int i=1;i<=n;i++){
    ll total=0;
    for(ll u:edges[i]){
      if(!s.count(u)){
        sum+=arr[u];
        s.insert(u);
      }
      total+=arr[u];
    }
    ans=__gcd(ans,total);
    ans=__gcd(ans,sum);
  }
  for(int i=1;i<=n;i++)edges[i].clear();
  cout<<ans<<'\n';
}
int main()
{
  boost;
  //cout<<fixed<<setprecision(10);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output03.txt","w",stdout);
  #endif
  ll T;
  cin>>T;
  for(int t=1;t<=T;t++){
    solve(t);
  }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long ll1;
typedef long double ld;
const ll MAX=5e5+5;
const double pi=atan(1)*4;
ll MOD=1e9+7;
#define pb push_back
#define se second
#define fi first
#define sb __builtin_popcount
#define maxe max_element
#define mine min_element
#ifndef ONLINE_JUDGE
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#else
#define debug(...)
#define debug2(...)
#define debug3(...)
#define debug4(...)
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fbo find_by_order
#define ook order_of_key
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define pll pair<ll,ll>
using namespace __gnu_pbds;
#define os1 tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define error 0.000000000000000001
template<class F>
int no_of_bits(F a){if(sizeof(a)==4)return 32-__builtin_clz(a);return 64-__builtin_clzll(a);}
ll add(ll a,ll b){return ((ll1)a+b)%MOD;}
ll mul(ll a,ll b){return ((ll1)a*b)%MOD;}
ll sub(ll a,ll b){return ((ll1)a-b+MOD)%MOD;}
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dt pair<pll,ll>
ll arr[MAX];
vector<ll>edges[MAX];
void solve(ll TC)
{
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>arr[i];
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    edges[b].pb(a);
  }
  map<vector<ll>,ll>mp;
  for(int i=1;i<=n;i++){
    vector<ll>v=edges[i];
    sort(v.begin(),v.end());
    mp[v]+=arr[i];
  }
  ll ans=0;
  for(auto u:mp){
    debug(u.se);
    ans=__gcd(ans,u.se);
  }
  for(int i=1;i<=n;i++)edges[i].clear();
  cout<<ans<<'\n';
}
int main()
{
  boost;
  //cout<<fixed<<setprecision(10);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output03.txt","w",stdout);
  #endif
  ll T;
  cin>>T;
  for(int t=1;t<=T;t++){
    solve(t);
  }
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long long ll1;
typedef long double ld;
const ll MAX=5e5+5;
const double pi=atan(1)*4;
ll MOD=1e9+7;
#define pb push_back
#define se second
#define fi first
#define sb __builtin_popcount
#define maxe max_element
#define mine min_element
#ifndef ONLINE_JUDGE
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define debug4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
#else
#define debug(...)
#define debug2(...)
#define debug3(...)
#define debug4(...)
#endif
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fbo find_by_order
#define ook order_of_key
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define pll pair<ll,ll>
using namespace __gnu_pbds;
#define os1 tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define error 0.000000000000000001
template<class F>
int no_of_bits(F a){if(sizeof(a)==4)return 32-__builtin_clz(a);return 64-__builtin_clzll(a);}
ll add(ll a,ll b){return ((ll1)a+b)%MOD;}
ll mul(ll a,ll b){return ((ll1)a*b)%MOD;}
ll sub(ll a,ll b){return ((ll1)a-b+MOD)%MOD;}
#define boost               ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define dt pair<pll,ll>
ll arr[MAX];
vector<ll>edges[MAX];
void solve(ll TC)
{
  ll n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)cin>>arr[i];
  for(int i=0;i<m;i++){
    ll a,b;
    cin>>a>>b;
    edges[b].pb(a);
  }
  map<vector<ll>,ll>mp;
  for(int i=1;i<=n;i++){
    vector<ll>v=edges[i];
    sort(v.begin(),v.end());
    if(v.size())mp[v]+=arr[i];
  }
  ll ans=0;
  for(auto u:mp){
    debug(u.se);
    ans=__gcd(ans,u.se);
  }
  for(int i=1;i<=n;i++)edges[i].clear();
  cout<<ans<<'\n';
}
int main()
{
  boost;
  //cout<<fixed<<setprecision(10);
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output03.txt","w",stdout);
  #endif
  ll T;
  cin>>T;
  for(int t=1;t<=T;t++){
    solve(t);
  }
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;

const int N = 500005;
ll ci[N];
ll l_col[N], r_col[N];
pair<ll, ll> v[N];

ll rnd() {
    ll x = 0;
    for (int i = 0; i < 6; i++)
        x = (x << 10) | (rand() & 1023);
    return x;
}

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
    int t;
    scanf("%d", &t);
    while (t) {
        int n, m;
        scanf("%d%d", &n, &m);
        for (int i = 0; i < n; i++) scanf("%lld", &ci[i]);
        for (int i = 0; i < n; i++) {
            l_col[i] = rnd();
            r_col[i] = 0;
        }
        ll l, r;
        for (int i = 0; i < m; i++) {
            scanf("%d%d", &l, &r);
            r_col[r - 1] ^= l_col[l - 1];
        }
        for (int i = 0; i < n; i++) {
            v[i] = make_pair(r_col[i], i);
        }
        sort(v, v + n);
        ll sum = 0, res = 0;
        for (int i = 0; i < n; i++) {
            sum += ci[v[i].second];
            if (i == n - 1 || v[i].first != v[i + 1].first) {
                if (v[i].first != 0) {
                    res = gcd(sum, res);
                }
                sum = 0;
            }
        }
        printf("%lld\n", res);
        t--;
    }
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;

const int N = 500005;
ll ci[N];
ll l_col[N], r_col[N];
pair<ll, ll> v[N];

ll rnd() {
    ll x = 0;
    for (int i = 0; i < 6; i++)
        x = (x << 10) | (rand() & 1023);
    return x;
}

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
    int t;
    scanf("%d", &t);
    while (t) {
        int n, m;
        scanf("%d%d", &n, &m);
        for (int i = 0; i < n; i++) scanf("%d", &ci[i]);
        for (int i = 0; i < n; i++) {
            l_col[i] = rnd();
            r_col[i] = 0;
        }
        ll l, r;
        for (int i = 0; i < m; i++) {
            scanf("%d%d", &l, &r);
            r_col[r - 1] ^= l_col[l - 1];
        }
        for (int i = 0; i < n; i++) {
            v[i] = make_pair(r_col[i], i);
        }
        sort(v, v + n);
        ll sum = 0, res = 0;
        for (int i = 0; i < n; i++) {
            sum += ci[v[i].second];
            if (i == n - 1 || v[i].first != v[i + 1].first) {
                if (v[i].first != 0) {
                    res = gcd(sum, res);
                }
                sum = 0;
            }
        }
        printf("%lld\n", res);
        t--;
    }
}


#include<bits/stdc++.h>

#define ll long long
using namespace std;

const int N = 500005;
ll ci[N];
ll l_col[N], r_col[N];
pair<ll, ll> v[N];

ll rnd() {
    ll x = 0;
    for (int i = 0; i < 6; i++)
        x = (x << 10) + (rand() & 1023);
    return x;
}

ll gcd(ll a, ll b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
    int t;
    cin >> t;
    while (t) {
        int n, m;
        cin >> n >> m;
        for (int i = 0; i < n; i++) cin >> ci[i];
        for (int i = 0; i < n; i++) {
            l_col[i] = rnd();
            r_col[i] = 0;
        }
        ll l, r;
        for (int i = 0; i < m; i++) {
            cin >> l >> r;
            r_col[r - 1] ^= l_col[l - 1];
        }
        for (int i = 0; i < n; i++) {
            v[i] = make_pair(r_col[i], i);
        }
        sort(v, v + n);
        ll sum = 0, res = 0;
        for (int i = 0; i < n; i++) {
            sum += ci[v[i].second];
            if (i == n - 1 || v[i].first != v[i + 1].first) {
                if (v[i].first != 0) {
                    res = gcd(sum, res);
                }
                sum = 0;
            }
        }
        cout << res << "\n";
        t--;
    }
}


#include "bits/stdc++.h"
using namespace std;
// #define endl '\n'
#define int long long

int gcd(int a, int b) {
	while (b > 0) {
		a %= b;
		swap(a, b);
	}
	return a;
}

void solve() {

	int n, m;
	cin >> n >> m;
	int la[n+1];
	for (int i=1; i<=n; i++) cin >> la[i];
	vector<int> adj[n+1];

	bool cr[n+1];
	memset(cr, 1, sizeof cr);

	for (int i=0; i<m; i++) {
		int l, r;
		cin >> l >> r;
		adj[r].push_back(l);
		cr[r] = false;
	}
	pair<vector<int>, int> tr[n+1];
	for (int i=1; i<=n; i++) {
		sort(adj[i].begin(), adj[i].end());
		tr[i] = make_pair(adj[i], i);
	}

	sort(tr+1, tr+n+1);

	int g = 0;
	int cs = 0;

	for (int i=1; i<=n; i++) {
		if (tr[i].first.empty()) continue;
		if (tr[i].first == tr[i-1].first) {
			cs += la[tr[i].second];
		}
		else {
			g = gcd(g, cs);
			cs = la[tr[i].second];
		}
	}

	g = gcd(g, cs);

	cout << g << endl;

}

signed main() {

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	int t;
	cin >> t;
	while (t--) solve();

}


#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {

	long long n, e;
	cin >> n >> e;
	long long v[n+1];
	long long sm = 0;
	for (long long i=1; i<=n; i++) {
		cin >> v[i];
		sm += v[i];
	}

	vector<int> adj[n+1];

	long long x = 0;
	long long ato[n+1];
	memset(ato, 0, sizeof ato);
	long long lsc[n+1];
	memset(lsc, 0, sizeof lsc);
	for (long long i=0; i<e; i++) {
		long long a, b;
		cin >> a >> b;
		lsc[a] += v[b];
		if (ato[b] == 0) {
			x += v[b];
		}
		ato[b]++;
		adj[a].push_back(b);
	}

	long long g = lsc[1];

	// cout << "all: " << x << endl;
	for (long long i=1; i<=n; i++) {
		// if i dont pick this
		long long w = 0;
		// cout << "not: " << i << endl;
		for (int j=0; j<adj[i].size(); j++) {
			if (ato[adj[i][j]] == 1) { // if this was the only node covering some other node, need remove
				// cout << "  rem: " << adj[i][j] << ' ' << v[adj[i][j]] << endl;
				w += v[adj[i][j]];
			}
		}
		// cout << "  not: " << i << ' ' << x << ' ' << w << endl;
		g = gcd(g, x - w);
	}

	for (long long i=2; i<=n; i++) g = gcd(g, lsc[i]);
	cout << gcd(gcd(g, x), sm) << endl;

}

int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	long long t;
	cin >> t;
	while (t--) solve();

}


#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {

	long long n, e;
	cin >> n >> e;
	long long v[n+1];
	for (long long i=1; i<=n; i++) cin >> v[i];

	long long x = 0;
	bool ato[n+1];
	memset(ato, 0, sizeof ato);
	long long lsc[n+1];
	memset(lsc, 0, sizeof lsc);
	for (long long i=0; i<e; i++) {
		long long a, b;
		cin >> a >> b;
		lsc[a] += v[b];
		if (!ato[b]) {
			ato[b] = true;
			x += v[b];
		}
	}

	long long g = lsc[1];
	for (long long i=2; i<=n; i++) g = gcd(g, lsc[i]);
	cout << gcd(g, x) << endl;

}

int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	long long t;
	cin >> t;
	while (t--) solve();

}


#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {

	long long n, e;
	cin >> n >> e;
	long long v[n+1];
	for (long long i=1; i<=n; i++) cin >> v[i];

	vector<int> adj[n+1];

	long long x = 0;
	int ato[n+1];
	memset(ato, 0, sizeof ato);
	long long lsc[n+1];
	memset(lsc, 0, sizeof lsc);
	for (long long i=0; i<e; i++) {
		long long a, b;
		cin >> a >> b;
		lsc[a] += v[b];
		if (ato[b] == 0) {
			x += v[b];
		}
		ato[b]++;
		adj[a].push_back(b);
	}

	long long g = lsc[1];

	// cout << "all: " << x << endl;
	for (long long i=1; i<=n; i++) {
		// if i dont pick this
		long long w = 0;
		// cout << "not: " << i << endl;
		for (int j=0; j<adj[i].size(); j++) {
			if (ato[adj[i][j]] == 1) { // if this was the only node covering some other node, need remove
				// cout << "  rem: " << adj[i][j] << ' ' << v[adj[i][j]] << endl;
				w += v[adj[i][j]];
			}
		}
		// cout << "  not: " << i << ' ' << x << ' ' << w << endl;
		g = gcd(g, x - w);
	}

	for (long long i=2; i<=n; i++) g = gcd(g, lsc[i]);
	cout << gcd(g, x) << endl;

}

int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	long long t;
	cin >> t;
	while (t--) solve();

}


#include "bits/stdc++.h"
using namespace std;

long long gcd(long long a, long long b) {
	while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

void solve() {

	long long n, e;
	cin >> n >> e;
	long long v[n+1];
	for (long long i=1; i<=n; i++) cin >> v[i];

	vector<int> adj[n+1];

	long long x = 0;
	int ato[n+1];
	memset(ato, 0, sizeof ato);
	long long lsc[n+1];
	memset(lsc, 0, sizeof lsc);
	for (long long i=0; i<e; i++) {
		long long a, b;
		cin >> a >> b;
		lsc[a] += v[b];
		if (!ato[b]) {
			x += v[b];
		}
		ato[b]++;
		adj[a].push_back(b);
	}

	for (long long i=1; i<=n; i++) {
		// if i dont pick this
		long long w = 0;
		for (int j=0; j<adj[i].size(); j++) {
			if (ato[adj[i][j]] == 1) {
				w += v[adj[i][j]];
			}
		}
		x = gcd(x, x - w);
	}

	long long g = lsc[1];
	for (long long i=2; i<=n; i++) g = gcd(g, lsc[i]);
	cout << gcd(g, x) << endl;

}

int main() {

	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

	long long t;
	cin >> t;
	while (t--) solve();

}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=1;
	For(x,1,n){
		int scnt=cnt;
		map <int,int> mp;
		for (auto y : e[x]){
			int v=id[y];
			if (v>=scnt)
				continue;
			if (mp[v]==0)
				mp[v]=cnt++;
			id[y]=mp[v];
		}
	}
	map <int,LL> s;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	for (auto p : s)
		ans=__gcd(ans,p.se);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	For(x,1,n){
		unordered_map <int,int> mp;
		for (auto y : e[x]){
			int v=id[y];
			if (mp[v]==0)
				mp[v]=++cnt;
			id[y]=mp[v];
		}
	}
	unordered_map <int,LL> s;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	for (auto p : s)
		if (p.fi!=0)
			ans=__gcd(ans,p.se);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N],z;
LL s[N];
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	s[0]=0;
	For(i,1,m)
		s[i]=0;
	For(x,1,n)
		if (!e[x].empty()){
			for (auto y : e[x]){
				int v=id[y];
				if (s[v]==0)
					s[v]=++cnt,z.pb(v);
				id[y]=s[v];
			}
			while (!z.empty())
				s[z.back()]=0,z.pop_back();
		}
	For(i,1,cnt)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,m)
		if (s[i]!=0)
			ans=__gcd(ans,s[i]);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
LL s[N];
int st[N],top=0;
LL gcd(LL x,LL y){
	return x?gcd(y%x,x):y;
}
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	s[0]=0;
	For(i,1,m)
		s[i]=0;
	For(x,1,n)
		if (!e[x].empty()){
			for (auto y : e[x]){
				int v=id[y];
				if (s[v]==0)
					s[v]=++cnt,st[++top]=v;
				id[y]=s[v];
			}
			while (top)
				s[st[top--]]=0;
		}
	For(i,1,cnt)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,m)
		if (s[i]!=0)
			ans=gcd(ans,s[i]);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
LL s[N];
int st[N],top=0;
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	s[0]=0;
	For(i,1,m)
		s[i]=0;
	For(x,1,n)
		if (!e[x].empty()){
			for (auto y : e[x]){
				int v=id[y];
				if (s[v]==0)
					s[v]=++cnt,st[++top]=v;
				id[y]=s[v];
			}
			while (top)
				s[st[top--]]=0;
		}
	For(i,1,cnt)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,m)
		if (s[i]!=0)
			ans=__gcd(ans,s[i]);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	For(x,1,n){
		map <int,int> mp;
		for (auto y : e[x]){
			int v=id[y];
			if (mp[v]==0)
				mp[v]=++cnt;
			id[y]=mp[v];
		}
	}
	map <int,LL> s;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	for (auto p : s)
		if (p.fi!=0)
			ans=__gcd(ans,p.se);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N];
vi e[N];
LL s[N];
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	For(x,1,n)
		if (!e[x].empty()){
			unordered_map <int,int> mp;
			for (auto y : e[x]){
				int v=id[y];
				if (mp[v]==0)
					mp[v]=++cnt;
				id[y]=mp[v];
			}
		}
	For(i,1,m)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,m)
		if (s[i]!=0)
			ans=__gcd(ans,s[i]);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N],s[N];
vi e[N];
int st[N],top=0;
LL gcd(LL x,LL y){
	return x?gcd(y%x,x):y;
}
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	s[0]=0;
	For(i,1,m)
		s[i]=0;
	For(x,1,n)
		if (!e[x].empty()){
			for (auto y : e[x]){
				int v=id[y];
				if (s[v]==0)
					s[v]=++cnt,st[++top]=v;
				id[y]=s[v];
			}
			while (top)
				s[st[top--]]=0;
		}
	For(i,1,cnt)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,cnt)
		if (s[i]!=0)
			ans=gcd(ans,s[i]);
	printf("%lld\n",ans);
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define outtime() cerr<<"User Time = "\
	<<(double)clock()/CLOCKS_PER_SEC<<endl
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int N=500005;
int n,m;
int id[N];
LL a[N],s[N];
vi e[N];
int st[N],top=0;
LL gcd(LL x,LL y){
	return x?gcd(y%x,x):y;
}
void Solve(){
	n=read(),m=read();
	For(i,1,n)
		e[i].clear();
	For(i,1,n)
		a[i]=read(),id[i]=0;
	For(i,1,m){
		int x=read(),y=read();
		e[x].pb(y);
	}
	int cnt=0;
	s[0]=0;
	For(i,1,m)
		s[i]=0;
	For(x,1,n)
		if (!e[x].empty()){
			for (auto y : e[x]){
				int v=id[y];
				if (s[v]==0)
					s[v]=++cnt,st[++top]=v;
				id[y]=s[v];
			}
			while (top)
				s[st[top--]]=0;
		}
	For(i,1,cnt)
		s[i]=0;
	For(i,1,n)
		s[id[i]]+=a[i];
	LL ans=0;
	For(i,1,cnt)
		if (s[i]!=0)
			ans=gcd(ans,s[i]);
	cout<<ans<<endl;
}
int main(){
	int T=read();
	while (T--)
		Solve();
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=500005;

int n,m;
bool vis[N];
LL a[N];
std::vector<int> e[N];

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

LL check()
{
	for (int i=1;i<=n;i++) vis[i]=0;
	LL ans=0;
	for (int i=1;i<=n;i++)
	{
		LL w=0;
		for (auto x:e[i])
			if (!vis[x]) vis[x]=1,w+=a[x];
		ans=gcd(ans,w);
	}
	return ans;
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) scanf("%lld",&a[i]),e[i].clear();
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[x].pb(y);
		}
		printf("%lld\n",check());
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=500005;

int n,m;
bool vis[N];
LL a[N];
std::vector<int> e[N];

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

LL check()
{
	for (int i=1;i<=n;i++) vis[i]=0;
	LL ans=0,r=0;
	for (int i=1;i<=n;i++)
	{
		LL w=0,v=0;
		for (auto x:e[i])
			if (!vis[x]) vis[x]=1,w+=a[x];
			else v+=a[x];
		ans=gcd(ans,w);
		ans=gcd(ans,v);
		ans=gcd(ans,r-v);
		r+=w;
	}
	return ans;
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) scanf("%lld",&a[i]),e[i].clear();
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[x].pb(y);
		}
		printf("%lld\n",check());
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=500005;

int n,m;
bool vis[N];
LL a[N],s[N],fac[N];
std::vector<int> e[N];

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

bool check(LL d)
{
	for (int i=1;i<=n;i++) vis[i]=0;
	for (int i=1;i<=n;i++)
	{
		LL w=0;
		for (auto x:e[i])
			if (!vis[x]) vis[x]=1,w+=a[x];
		if (w%d!=0) return 0;
	}
	return 1;
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) scanf("%lld",&a[i]),e[i].clear(),s[i]=0;
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[x].pb(y);
			s[x]+=a[y];
		}
		LL d=0;
		for (int i=1;i<=n;i++) d=gcd(d,s[i]);
		int tot=0;
		for (LL i=1;i*i<=d;i++)
			if (d%i==0) fac[++tot]=i,fac[++tot]=d/i;
		std::sort(fac+1,fac+tot+1);
		for (int i=tot;i>=1;i--)
			if (check(fac[i]))
			{
				printf("%lld\n",fac[i]);
				break;
			}
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=500005;

int n,m,id[N];
LL a[N];
std::vector<int> e[N];

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

bool cmp(int x,int y)
{
	int k=std::min(e[x].size(),e[y].size());
	for (int i=0;i<k;i++)
		if (e[x][i]<e[y][i]) return 1;
		else if (e[x][i]>e[y][i]) return 0;
	return e[x].size()<e[y].size();
}

bool cmp1(int x,int y)
{
	int k=std::min(e[x].size(),e[y].size());
	if (e[x].size()!=e[y].size()) return 0;
	for (int i=0;i<k;i++)
		if (e[x][i]!=e[y][i]) return 0;
	return 1;
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) scanf("%lld",&a[i]),e[i].clear();
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[y].pb(x);
		}
		for (int i=1;i<=n;i++) std::sort(e[i].begin(),e[i].end());
		for (int i=1;i<=n;i++) id[i]=i;
		std::sort(id+1,id+n+1,cmp);
		LL ans=0;
		for (int i=1;i<=n;i++)
		{
			if (!e[id[i]].size()) continue;
			LL s=a[id[i]];
			int j=i;
			while (j<n&&cmp1(id[i],id[j+1])) j++,s+=a[id[j]];
			ans=gcd(ans,s);
			i=j;
		}
		printf("%lld\n",ans);
	}
	return 0;
}


#include<bits/stdc++.h>
#define pb push_back

typedef long long LL;

const int N=500005;

int n,m;
bool vis[N];
LL a[N];
std::vector<int> e[N];

LL gcd(LL x,LL y)
{
	if (!y) return x;
	else return gcd(y,x%y);
}

LL check()
{
	for (int i=1;i<=n;i++) vis[i]=0;
	LL ans=0;
	for (int i=1;i<=n;i++)
	{
		LL w=0,v=0;
		for (auto x:e[i])
			if (!vis[x]) vis[x]=1,w+=a[x];
			else v+=a[x];
		ans=gcd(ans,w);
		ans=gcd(ans,v);
	}
	return ans;
}

int main()
{
	int T;scanf("%d",&T);
	while (T--)
	{
		scanf("%d%d",&n,&m);
		for (int i=1;i<=n;i++) scanf("%lld",&a[i]),e[i].clear();
		for (int i=1;i<=m;i++)
		{
			int x,y;scanf("%d%d",&x,&y);
			e[x].pb(y);
		}
		printf("%lld\n",check());
	}
	return 0;
}


n,l = map(int,raw_input().split())

a = map(int,raw_input().split())
a = sorted(a)
b = []

if(n==1 and l==a[0]):
	print "%.9f" % l
else:
	for i in range(len(a)-1):
		b.append(a[i+1]-a[i])
	try:
		x = max(i for i in b)/2.0

		x = max(x,max(a[0]-0,l-a[-1]))

		print "%.9f" % x
	except:
		print "%.9f" % 1.0


from itertools import chain

n, l = map(int, raw_input().split())
locs = sorted(map(int, raw_input().split()))

pairs = zip(locs, locs[1:])

between = 0
if len(pairs) > 0:
	between = max(b - a for a, b in pairs) / 2.0

start = locs[0]
end = l - locs[-1]

print max(between, start, end)


from itertools import chain

n, l = map(int, raw_input().split())
locs = sorted(map(int, raw_input().split()))

pairs = zip(locs, locs[1:])

between = max(b - a for a, b in pairs) / 2.0
start = locs[0]
end = l - locs[-1]

print max(between, start, end)


p = [int(x) for x in raw_input().split()]
n = p[0]
l = p[1]
g = [int(x) for x in raw_input().split()]
g.append(0)
g.append(l)
g.sort()
m = 0
for i in range(0, len(g) - 1):
    if g[i + 1] - g[i] > m:
        m = g[i + 1] - g[i]
print float(m / 2.0)


p = [int(x) for x in raw_input().split()]
n = p[0]
l = p[1]
g = [int(x) for x in raw_input().split()]
g.sort()
m = 0
for i in range(0, len(g) - 1):
    if g[i + 1] - g[i] > m:
        m = g[i + 1] - g[i]
m = float(m / 2.0)
if g[0] - 0 > m:
    m = g[0] - 0
if l - g[len(g) - 1] > m:
    m = l - g[len(g) - 1]
print m


p = [int(x) for x in raw_input().split()]
n = p[0]
l = p[1]
g = [int(x) for x in raw_input().split()]
g.sort()
m = 0
for i in range(0, len(g) - 1):
    if g[i + 1] - g[i] > m:
        m = g[i + 1] - g[i]
print float(m / 2.0)


n, l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
print format(max(max([(a[i + 1] - a[i])/2.0 for i in range(n - 1)]), l - a[n - 1], a[0]),'.9f')


n, l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
d = max((l - a[n - 1]) * 2, a[0] * 2)
for i in range(n - 1):
    d = max(a[i + 1] - a[i], d)
d = d / 2.0
print format(d, '.9f')


n, l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
d = a[0]
for i in range(n - 1):
    d = max(a[i + 1] - a[i], d)
d = d / 2.0
print format(d, '.9f')


import math
#n = int(raw_input())
#a = [int(raw_input())for i in xrange(n)]
n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]
#a = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)]

if n == 1:
    print d
    quit()
'''
if 0 not in a:
    a.append(0)
if l not in a:
    a.append(l)'''
sa = sorted(a)
#print sa
#print [sa[i] - sa[i - 1] for i in xrange(1, len(sa))]
d = max([sa[i] - sa[i - 1] for i in xrange(1, len(sa))]) / 2.
if l not in a and l - sa[-1] > d * 2:
    d = (l - sa[-1]) / 2.
if 0 not in a and sa[0] > d:
    d = sa[0]
print d


import math
#n = int(raw_input())
#a = [int(raw_input())for i in xrange(n)]
n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]
#a = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)]

if n == 1:
    print d
    quit()

sa = sorted(a)
d = sa[0]
for i in xrange(1, n):
    #print sa[i], sa[i - 1], d
    if sa[i] - sa[i - 1] - d > d:
        d = (sa[i] - sa[i - 1]) / 2.
if l - sa[-1] - d > d:
    d = (l - sa[- 1]) / 2.

print d


import math

n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]

if n == 1:
    x = a[0]
    print max(x, l - x)
    quit()

#sa = list(set(sorted(a)))
sa = sorted(a)
#print sa
d = sa[0]
for i in xrange(1, n):
    if sa[i - 1] + d < sa[i] - d:
        d = (sa[i] - sa[i - 1]) / 2.

#print l, d, sa[-1]
if l not in a and sa[-1] + d < l:
    d = l - sa[- 1]

print d


import math
#n = int(raw_input())
#a = [int(raw_input())for i in xrange(n)]
n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]
#a = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)]

if n == 1:
    print d
    quit()

sa = sorted(a)
d = sa[0]
for i in xrange(1, n):
    #print sa[i], sa[i - 1], d
    if sa[i] - sa[i - 1] - d > d:
        d = (sa[i] - sa[i - 1]) / 2.

print d


import math
#n = int(raw_input())
#a = [int(raw_input())for i in xrange(n)]
n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]
#a = [[int(x)for x in raw_input().split(' ')]for i in xrange(n)]

if n == 1:
    print d
    quit()

sa = list(set(sorted(a)))
#print sa
d = sa[0]
for i in xrange(1, len(sa)):
    if sa[i] - sa[i - 1] - d > d:
        d = (sa[i] - sa[i - 1]) / 2.
if l - sa[-1] - d > d:
    d = (l - sa[- 1])

print d


import math

n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]

if n == 1:
    x = a[0]
    if x not in [0, l]:
        print max(x, l - x)
    else:
        print l
    quit()

#sa = list(set(sorted(a)))
sa = sorted(a)
#print sa
d = sa[0]
for i in xrange(1, n):
    if sa[i - 1] + d < sa[i] - d:
        d = (sa[i] - sa[i - 1]) / 2.

if l not in a and sa[-1] + d < l - d:
    d = l - sa[- 1]

print d


import math

n, l = [int(x)for x in raw_input().split(' ')]
a = [int(x)for x in raw_input().split(' ')]

if n == 1:
    print a[0]
    quit()

#sa = list(set(sorted(a)))
sa = sorted(a)
#print sa
d = sa[0]
for i in xrange(1, n):
    if sa[i - 1] + d < sa[i] - d:
        d = (sa[i] - sa[i - 1]) / 2.

if l not in a and sa[-1] + d < l - d:
    d = l - sa[- 1]

print d


n, L = map(int, raw_input().split())

x = map(float, raw_input().split())
x.sort()
r = 0
if x[0] != 0:
    r = x[0]
for i in xrange(n - 1):
    r = max(r, (x[i+1] - x[i]) / 2.0)

if x[-1] != L:
    r = max(r, (L - x[-1]))
print r


n, L = map(int, raw_input().split())

x = map(float, raw_input().split())
x.sort()
r = 0
if x[0] != 0:
    r = x[0]
for i in xrange(n - 1):
    r = max(r, (x[i+1] - x[i]) / 2.0)

print r


I = lambda:map(int,raw_input().split())
n,l = I()
lis = sorted(list(I()))

if min(lis)!=0:
    d = min(lis)
else:
    d = 0.5

if max(lis)!=l:
    lis.insert(len(lis)-1,l)

while True:
    p = 0
    for i in range(len(lis)-1):
        if lis[i]+d >= lis[i+1]-d:
            p = p+1
        else:
            break
    if p == len(lis)-1:
        print d
        break
    d = d+0.5


I = lambda:map(int,raw_input().split())
n,l = I()
lis = sorted(list(I()))
diff_l =[]
if n == 1:
    if l == n:
        print l/1.0
    else:
        print l-lis[0]/1.0
else:

    for i in range(1,n):
        diff_l.append(lis[i]-lis[i-1])

    if min(lis)!=0 and max(lis)!=l:
        print max(lis[0],diff_l[len(diff_l)-1]-diff_l[len(diff_l)-2],l-max(lis))/1.0
    elif min(lis)!=0:
        print max(lis[0],diff_l[len(diff_l)-1]-diff_l[len(diff_l)-2])/1.0
    elif max(lis)!=l:
        print max(diff_l[len(diff_l)-1] - diff_l[len(diff_l)-2], l-max(lis))/1.0
    else:
        print (max(diff_l) / 2.0)


I = lambda:map(int,raw_input().split())
n,l = I()
lis = sorted(list(I()))
diff_l =[]

for i in range(n-1):
    diff_l.append(lis[i+1]-lis[i])

if diff_l != []:
    print max(lis[0],max(diff_l)/2.0,l-lis[len(lis)-1])/1.0
else:
    if lis[0]==l or lis[0]==0:
        print l/1.0
    else:
        print max(l-lis[0],lis[0]-0)/1.0


I = lambda:map(int,raw_input().split())
n,l = I()
lis = sorted(list(I()))
print lis
diff_l =[]
if n == 1:
    if l == n:
        print l/1.0
    else:
        print l-lis[0]/1.0
else:

    for i in range(1,n):
        diff_l.append(lis[i]-lis[i-1])

    print diff_l,max(diff_l)

    if min(lis)!=0 and max(lis)!=l:
        print max(lis[0],diff_l[len(diff_l)-1]-diff_l[len(diff_l)-2],l-max(lis))/1.0
    elif min(lis)!=0:
        print max(lis[0],diff_l[len(diff_l)-1]-diff_l[len(diff_l)-2])/1.0
    elif max(lis)!=l:
        print max(diff_l[len(diff_l)-1] - diff_l[len(diff_l)-2], l-max(lis))/1.0
    else:
        print (max(diff_l) / 2.0)


temp = map(int,raw_input().split(" "))
a = map(int,raw_input().split(" "))
if len(a) == 1 :
	print a[0]
else:
	a = sorted(a)
	min_dis = max([(a[i+1]-a[i]) for i in range(temp[0]-1)])
	min_dis2 = max((a[0]-0),temp[1]-a[-1])
	if min_dis2 > min_dis/2 :
		print float(min_dis2)
	else:
		print float(min_dis)/2


temp = map(int,raw_input().split(" "))
a = map(int,raw_input().split(" "))
if len(a) == 1 :
	print float(max(a[0]-0,temp[1]-a[0]))
else:
	a = sorted(a)
	min_dis = max([(a[i+1]-a[i]) for i in range(temp[0]-1)])
	min_dis2 = max((a[0]-0),temp[1]-a[-1])
	if min_dis2 > min_dis/2 :
		print float(min_dis2)
	else:
		print float(min_dis)/2


temp = map(int,raw_input().split(" "))
a = map(int,raw_input().split(" "))
a = sorted(a)
min_dis = max([(a[i+1]-a[i]) for i in range(temp[0]-1)])
min_dis2 = max((a[0]-0),temp[1]-a[-1])
if min_dis2 > min_dis/2 :
	print float(min_dis2)
else:
	print float(min_dis)/2


nl = raw_input()
n = int(nl.split()[0])
l = int(nl.split()[1])
s = raw_input().split()
lanterns = []
for k in s:
    lanterns.append(int(k))
lanterns.sort()
differences = []
for i in range(len(lanterns) - 1):
    differences.append(lanterns[i+1]-lanterns[i])
d = max(differences)
print max((d+0.0)/2, 0.0+lanterns[0],0.0+l-lanterns[-1])


nl = raw_input()
n = int(nl.split()[0])
l = int(nl.split()[1])
s = raw_input().split()
lanterns = []
for k in s:
    lanterns.append(int(k))
lanterns.sort()
differences = []
for i in range(len(lanterns) - 1):
    differences.append(lanterns[i+1]-lanterns[i])
d = max(differences)
print max((d+1)/2, lanterns[0],l-lanterns[-1])


nl = raw_input()
n = int(nl.split()[0])
l = int(nl.split()[1])
s = raw_input().split()
lanterns = []
for k in s:
    lanterns.append(int(k))
lanterns.sort()
differences = []
if len(lanterns) == 1:
    print max(0.0+lanterns[0],0.0+l-lanterns[0])
for i in range(len(lanterns) - 1):
    differences.append(lanterns[i+1]-lanterns[i])
d = max(differences)
print max((d+0.0)/2, 0.0+lanterns[0],0.0+l-lanterns[-1])


nl = raw_input()
n = int(nl.split()[0])
l = int(nl.split()[1])
s = raw_input().split()
lanterns = []
for k in s:
    lanterns.append(int(k))
lanterns.sort()
differences = []
if len(lanterns) == 1:
    print max(0.0+lanterns[0],0.0+l-lanterns[0])
else:
    for i in range(len(lanterns) - 1):
        differences.append(lanterns[i+1]-lanterns[i])
    d = max(differences)
    print max((d+0.0)/2, 0.0+lanterns[0],0.0+l-lanterns[-1])


n,l=[long(num) for num in raw_input().split()]
points,d=[long(nums) for nums in raw_input().split()],0.0
points.sort()
for i in range(n):
    if not i and i<>(n-1):
        d=points[i]
    elif i==(n-1):
        if (l-points[i])>=d:
            d=max((((points[i]+points[i-1])/2.0)-points[i-1]),(l-points[i]))
    else:
        if ((points[i-1]+d)<(points[i]-d)):
            d=(((points[i]+points[i-1])/2.0)-points[i-1])
print "{0:.10f}".format(d)


n,l=[long(num) for num in raw_input().split()]
points,d=[long(nums) for nums in raw_input().split()],0.0
points.sort()
for i in range(n):
    if not i and i<>(n-1):
        d=points[i]
    elif i==(n-1):
        if (l-points[i])>d:
            d=(l-points[i])
    else:
        if ((points[i-1]+d)<(points[i]-d)):
            d=((points[i]+points[i-1])/2.0)-points[i-1]
print "{0:.10f}".format(d)


n,l=[long(num) for num in raw_input().split()]
points,d=[long(nums) for nums in raw_input().split()],0.0
points.sort()
if n==1:
    d=max(points[0],l-points[i])
else:
    for i in range(n):
        if not i and i<>(n-1):
            d=points[i]
        elif i==(n-1):
            if (l-points[i])>=d:
                d=max((((points[i]+points[i-1])/2.0)-points[i-1]),(l-points[i]))
        else:
            if ((points[i-1]+d)<(points[i]-d)):
                d=(((points[i]+points[i-1])/2.0)-points[i-1])
print "{0:.10f}".format(d)


n,l=[long(num) for num in raw_input().split()]
points,d=[long(nums) for nums in raw_input().split()],0.0
points.sort()
if n==1:
    d=max(points[0],l-points[0])
else:
    for i in range(n):
        if not i and i<>(n-1):
            d=points[i]
        elif i==(n-1):
            if ((points[i-1]+d)<(points[i]-d)):
                d=(((points[i]+points[i-1])/2.0)-points[i-1])
            if (l-points[i])>=d:
                d=max(d,(l-points[i]))
        else:
            if ((points[i-1]+d)<(points[i]-d)):
                d=(((points[i]+points[i-1])/2.0)-points[i-1])
print "{0:.10f}".format(d)


n,l=[long(num) for num in raw_input().split()]
points,d=[long(nums) for nums in raw_input().split()],0.0
points.sort()
if n==1:
    d=max(points[0],l-points[0])
else:
    for i in range(n):
        if not i and i<>(n-1):
            d=points[i]
        elif i==(n-1):
            if (l-points[i])>=d:
                d=max((((points[i]+points[i-1])/2.0)-points[i-1]),(l-points[i]))
        else:
            if ((points[i-1]+d)<(points[i]-d)):
                d=(((points[i]+points[i-1])/2.0)-points[i-1])
print "{0:.10f}".format(d)


from __future__ import division

n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
max1=2*max(a[0],l-a[n-1])

for i in range(n-1):
    if((a[i+1]-a[i])>max1):
        max1=a[i+1]-a[i]
print ("{0:.10f}".format(max1/2.0))


from __future__ import division

n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
max2=max(a[0],n-a[n-1])
max1=0
for i in range(n-1):
    if((a[i+1]-a[i])>max1):
        max1=a[i+1]-a[i]
print ("{0:.10f}".format(max(max1/2,max2)))


from __future__ import division

n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
max2=max(a[0],n-a[n-1])
max1=0
for i in range(n-1):
    if((a[i+1]-a[i])>max1):
        max1=a[i+1]-a[i]
print ("{0:.9f}".format(max(max1/2,max2)))


from __future__ import division

n,l=map(int,raw_input().split())
a=map(int,raw_input().split())
a.sort()
max1=2*max(a[0],n-a[n-1])

for i in range(n-1):
    if((a[i+1]-a[i])>max1):
        max1=a[i+1]-a[i]
print ("{0:.10f}".format(max1/2))


n,t = map(int,raw_input().split())
l = list(map(int,raw_input().split()))
l =  sorted(l)
m =float(0)
for i in range(0,n-1):
	m = max(l[i+1]-l[i],m)
m = float(m)/2
if l[0] != 0:
	m = max(m,l[0]-0)
if l[n-1]!=t:
	m = max(m,t-l[n-1])
m = float(m)
print str(m)+'0'*8


n,t = map(int,raw_input().split())
l = list(map(int,raw_input().split()))
l =  sorted(l)
m =0
for i in range(0,n-1):
	m = max(l[i+1]-l[i],m)
m = float(m)/2
if l[0] != 0:
	m = max(m,l[0]-0)
if l[n-1]!=t:
	m = max(m,t-l[n-1])
print str(m)+'0'*8


import fileinput

list = []

def solve(n, l):
#	if(not(0 in list)):
#		list.insert(0, 0)
#	if(not(l in list)):
#		list.extend(l)
	if(len(list) == 1):
		print list[0]-0.0
		return
	list.sort()
	max = 0.0
	for idx, val in enumerate(list):
		#print idx, " ", val
		if(idx == 0):
			max = val-0.0
		else:
			if((val - list[idx-1])/2.0 > max):
				max = (val - list[idx-1])/2.0
	if(l - list[-1] > max):
	   max = l - list[-1]
	print str(max)

if __name__ == '__main__':
	n, l = map(int, raw_input().split())
	list = map(int, raw_input().split())
	solve(n, l)


import fileinput

list = []

def solve(n, l):
#	if(not(0 in list)):
#		list.insert(0, 0)
#	if(not(l in list)):
#		list.extend(l)
	if(len(list) == 1):
		print str(l/2.0)
		return
	list.sort()
	max = 0.0
	for idx, val in enumerate(list):
		#print idx, " ", val
		if(idx == 0):
			max = val-0.0
		else:
			if((val - list[idx-1])/2.0 > max):
				max = (val - list[idx-1])/2.0
	if(l - list[-1] > max):
	   max = l - list[-1]
	print str(max)

if __name__ == '__main__':
	n, l = map(int, raw_input().split())
	list = map(int, raw_input().split())
	solve(n, l)


import fileinput

list = []

def solve(n, l):
#	if(not(0 in list)):
#		list.insert(0, 0)
#	if(not(l in list)):
#		list.extend(l)
	if(len(list) == 1):
		print max(list[0]-0.0, l-list[0])
		return
	list.sort()
	maxV = 0.0
	for idx, val in enumerate(list):
		#print idx, " ", val
		if(idx == 0):
			maxV = val-0.0
		else:
			if((val - list[idx-1])/2.0 > maxV):
				maxV = (val - list[idx-1])/2.0
	if(l - list[-1] > maxV):
	   maxV = l - list[-1]
	print str(maxV)

if __name__ == '__main__':
	n, l = map(int, raw_input().split())
	list = map(int, raw_input().split())
	solve(n, l)


s = raw_input().split()
s = [int(x) for x in s]
n = s[0]
l = s[1]
a = raw_input().split()
a = [int(x) for x in a]

a.sort()
max_diff = 0

for i in range(n):
    if i == 0 and a[i] != 0:
        max_diff = 2 * a[i]
    if i == n-1 and a[i] != l:
        max_diff = max(max_diff,2 * (l - a[i]))
    else:
        max_diff = max(max_diff,a[i] - a[i-1])

print(float(max_diff) / float(2))


s = raw_input().split()
s = [int(x) for x in s]
n = s[0]
l = s[1]
a = raw_input().split()
a = [int(x) for x in a]

a.sort()
max_diff = 0

for i in range(n):
    if i == 0 and a[i] != 0:
        max_diff = 2 * a[i]
    if i == n-1 and a[i] != n:
        max_diff = max(max_diff,2 * (n - a[i]))
    else:
        max_diff = max(max_diff,a[i] - a[i-1])

print(float(max_diff) / float(2))


n, l = map(int, raw_input().strip().split())
arr = map(int, raw_input().strip().split())
arr.sort()
dist = 0
for i in xrange(len(arr) - 1):
    d = arr[i+1] - arr[i]
    if d > dist:
        dist = d

if arr[0] != 0:
    d = arr[0] * 2
    if d > dist:
        dist = d

print dist/2.


n, l = map(int, raw_input().strip().split())
arr = map(int, raw_input().strip().split())
arr.sort()
dist = 0
for i in xrange(len(arr) - 1):
    d = arr[i+1] - arr[i]
    if d > dist:
        dist = d

d = arr[0] * 2
if d > dist:
    dist = d

d = (l - arr[-1]) * 2
if d > dist:
    dist = d

print dist/2.


p = raw_input()
d = p.split()
n = int(d[0])
l = int(d[1])
a = raw_input()
b = a.split()
i =0
lst = []
while(i < n):
    lst.append(int(b[i]))
    i+=1
lst.sort()
print lst
j = 1
maxdist = 0
while(j < n):
    if(lst[j] - lst[j-1] >= maxdist):
        maxdist = lst[j] - lst[j-1]
    j+=1
maxdist = maxdist/2.0
if(l - lst[j-1] >= maxdist ):
    maxdist = l-lst[j-1]
if(lst[0] - 0 >= maxdist):
    maxdist = lst[0] - 0
maxdist = str(maxdist)
if(maxdist.count(".") == 1):
    dotindex = maxdist.index(".")
    z = len(maxdist)-1-dotindex
    print str(maxdist)+"0"*(10-z)
else:
    print str(maxdist)+".0000000000"


p = raw_input()
d = p.split()
n = int(d[0])
l = int(d[1])
a = raw_input()
b = a.split()
i =0
lst = []
while(i < n):
    lst.append(int(b[i]))
    i+=1
lst.sort()
j = 1
maxdist = 0
while(j < n):
    if(lst[j] - lst[j-1] >= maxdist):
        maxdist = lst[j] - lst[j-1]
    j+=1
maxdist = maxdist/2.0
if(l - lst[j-1] >= maxdist ):
    maxdist = l-lst[j-1]
if(lst[0] - 0 >= maxdist):
    maxdist = lst[0] - 0
maxdist = float(maxdist)
maxdist = str(maxdist)
dotindex = maxdist.index(".")
z = len(maxdist)-1-dotindex
print str(maxdist)+"0"*(10-z)


p = raw_input()
d = p.split()
n = int(d[0])
l = int(d[1])
a = raw_input()
b = a.split()
i =0
lst = []
while(i < n):
    lst.append(int(b[i]))
    i+=1
lst.sort()
print lst
j = 1
maxdist = 0
while(j < n):
    if(lst[j] - lst[j-1] >= maxdist):
        maxdist = lst[j] - lst[j-1]
    j+=1
maxdist = maxdist/2.0
if(l - lst[j-1] >= maxdist ):
    maxdist = l-lst[j-1]
if(lst[0] - 0 >= maxdist):
    maxdist = lst[0] - 0
print maxdist


p = raw_input()
d = p.split()
n = int(d[0])
l = int(d[1])
a = raw_input()
b = a.split()
i =0
lst = []
while(i < n):
    lst.append(int(b[i]))
    i+=1
lst.sort()
print lst
j = 1
maxdist = 0
while(j < n):
    if(lst[j] - lst[j-1] >= maxdist):
        maxdist = lst[j] - lst[j-1]
    j+=1
maxdist = maxdist/2.0
if(l - lst[j-1] >= maxdist ):
    maxdist = l-lst[j-1]
if(lst[0] - 0 >= maxdist):
    maxdist = lst[0] - 0
print '%f' % maxdist


n,l = map(int,raw_input().split())
a = sorted(map(int,raw_input().split()))
x = max([a[0], l-a[n-1]] + [(a[i+1]-a[i])/2 for i in range(n-1)])
print(x)


n,l = map(int,raw_input().split())
a=sorted(map(int,raw_input().split()))
x=[a[0], l-a[n-1]]
for i in range(n-1):
    x.append((a[i+1]-a[i])/2.0)
print(max(x))


n,l = map(int,raw_input().split())
a = sorted(map(int,raw_input().split()))
x = max([a[0], l-a[n-1]] + [(a[i+1]-a[i])/2.0 for i in range(n-1)])
print(x)


n,l = map(int,raw_input().split())
a = sorted(map(int,raw_input().split()))
x = max(a[i+1]-a[i] for i in range(n-1))
print(x/2.0)


f=lambda:map(int,raw_input().split())
n,l=f()
a=f()
print max(min(a),l-max(a),max(x-y for x,y in zip(a[1:],a))/2.0)


f=lambda:map(int,raw_input().split())
n,l=f()
a=sorted(f())
print max([a[0],l-a[-1]]+[(x-y)/2.0 for x,y in zip(a[1:],a)])


f=lambda:map(int,raw_input().split())
n,l=f()
a=sorted(f())
print max(a[0],l-a[-1],max(x-y for x,y in zip(a[1:],a))/2.0)


l,d=map(int,raw_input().split())
arr=map(int,raw_input().split())
arr.sort()
k=[]
if 0 not in arr:
	k.append(arr[0]*2)
for j in range(l-1):
	k.append(arr[j+1]-arr[j])
if d not in arr:
	k.append((d-arr[len(arr)-1])*2)
print float(max(k))/2


l,d=map(int,raw_input().split())
arr=map(int,raw_input().split())
arr.sort()
k=[]
if 0 not in arr:
	k.append(arr[0]*2)
for j in range(l-1):
	k.append(arr[j+1]-arr[j])
print float(max(k))/2


n,l=map(int,raw_input().split())
arr=map(int,raw_input().split())
arr.sort()
d=[]
if (arr.count(0)==0):
	d.append(arr[0]-0)

for i in range(1,n):
	d.append((arr[i]-arr[i-1])/2.0)
if(arr.count(l)==0):
	d.append(l-arr[-1])
d.sort()

if(arr[0]-0 > d[-1]):
	print float(arr[0]-0)
else:

	print float(d[-1])


n,l=map(int,raw_input().split())
arr=map(int,raw_input().split())
arr.sort()
d=[]
if (arr.count(0)==0):
	d.append(arr[0]-0)

for i in range(1,n):
	d.append(arr[i]-arr[i-1])
if(arr.count(l)==0):
	d.append(l-arr[-1])
d.sort()
if(arr[0]-0 > d[-1]/2.0):
	print float(arr[0]-0)
else:

	print d[-1]/2.0


n,l=map(int,raw_input().split())
arr=map(int,raw_input().split())
arr.sort()
d=[]
if (arr.count(0)==0):
	d.append(arr[0]-0)

for i in range(1,n):
	d.append(arr[i]-arr[i-1]/2.0)
if(arr.count(l)==0):
	d.append(l-arr[-1])
d.sort()
if(arr[0]-0 > d[-1]):
	print float(arr[0]-0)
else:

	print float(d[-1])


a = raw_input().split(" ")
b = raw_input().split(" ")

maior = -1.0
anterior = 0.0

for passnum in range(0,len(b)-1):
	for i in range(len(b)-1):
		b[i] = float(b[i])
		b[i+1] = float(b[i+1])
		if b[i]>b[i+1]:
			temp = b[i]
			b[i] = b[i+1]
			b[i+1] = temp

for x in b:

	if(maior == -1.0):
		maior = x
	elif ((x-anterior)>(maior/2.0)):
		maior = (x-anterior)/2.0
		anterior = x

print maior


a = raw_input().split(" ")
b = raw_input().split(" ")

maior = -1.0
anterior = 0.0

for passnum in range(0,len(b)-1):
	for i in range(len(b)-1):
		b[i] = float(b[i])
		b[i+1] = float(b[i+1])
		if b[i]>b[i+1]:
			temp = b[i]
			b[i] = b[i+1]
			b[i+1] = temp

for x in b:

	if(maior == -1.0):
		maior = x
	elif ((x-anterior)/2.0>maior):
		maior = (x-anterior)/2.0
	anterior = x

k = float(a[1])
y = float(anterior)
maior = float(maior)

if (k-y)>(maior):
	maior = (k-y)

print maior


a = raw_input().split(" ")
b = raw_input().split(" ")

maior = -1.0
anterior = 0.0

for passnum in range(len(b)-1,0,-1):
	for i in range(passnum):
		if float(b[i])>float(b[i+1]):
			temp = float(b[i])
			b[i] = float(b[i+1])
			b[i+1] = temp

print b

for x in b:
	print x
	print x-maior
	print maior/2.0
	print (x-maior)/2

	if(maior == -1.0):
		maior = x
	elif ((x-anterior)>(maior/2.0)):
		maior = (x-anterior)/2.0
		anterior = x
	print "maior " + str(maior)

print maior


a = raw_input().split(" ")
b = raw_input().split(" ")

maior = -1.0
anterior = 0.0

for passnum in range(0,len(b)-1):
	for i in range(len(b)-1):
		b[i] = float(b[i])
		b[i+1] = float(b[i+1])
		if b[i]>b[i+1]:
			temp = b[i]
			b[i] = b[i+1]
			b[i+1] = temp

for x in b:

	if(maior == -1.0):
		maior = x
	elif ((x-anterior)>(maior/2.0)):
		maior = (x-anterior)/2.0
	anterior = x

k = float(a[1])
y = float(anterior)
maior = float(maior)

if (k-y)>(maior/2.0):
	maior = (k-y)

print maior


a = raw_input().split(" ")
b = raw_input().split(" ")

maior = -1.0
anterior = 0.0

for passnum in range(0,len(b)-1):
	for i in range(len(b)-1):
		b[i] = float(b[i])
		b[i+1] = float(b[i+1])
		if b[i]>b[i+1]:
			temp = b[i]
			b[i] = b[i+1]
			b[i+1] = temp

for x in b:

	if(maior == -1.0):
		maior = x
	elif ((x-anterior)/2.0>maior):
		maior = (x-anterior)/2.0
	anterior = x

k = float(a[1])
y = float(anterior)
maior = float(maior)

if ((k-y)/2.0)>(maior):
	maior = (k-y)

print maior


n,l=map(int,raw_input().split())
lis=list(map(int,raw_input().split()))
s=list()
lis.sort()
for i in range(n-1):
    s.append(lis[i+1]-lis[i])
if s!=[] :   m=[max(s)/2.0,lis[0],l-lis[n-1]]
else:m=[lis[0],l-lis[n-1]]
print max(m)


n,l=map(int,raw_input().split())
l=list(map(int,raw_input().split()))
s=list()
l.sort()
for i in range(n-1):
    s.append(l[i+1]-l[i])
if l[0]!=0 and max(s)/2.0<l[0]:print l[0]
else:print max(s)/2.0


n,l=map(int,raw_input().split())
lis=list(map(int,raw_input().split()))
s=list()
lis.sort()
for i in range(n-1):
    s.append(lis[i+1]-lis[i])
m=[max(s)/2.0,lis[0],l-lis[n-1]]
print max(m)


__author__ = 'ckboss'

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-9

list = []
for x in numbers:
    list.append(float(x))

list = sorted(list)

#print list

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    pos = list[0]+x
    for i in range(1,n):
        #print "%r %r %r %r" % (i,list[i],pos,x)
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    if list[n-1]+x + eps > l:
        return True
    else :
        return False

#print checkD(200)

low = 0.
high = 1000000000.
ans = -1.

loop = 0
while low + eps <= high and loop < 200 :
    mid = (low+high)/2.
    #print "low: %r mid %r high %r" % (low,mid,high)
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid
    loop+=1

print "%.11lf" % ans


__author__ = 'ckboss'

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-9

list = []
for x in numbers:
    list.append(float(x))

list.append(l)
n+=1
list = sorted(list)

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    pos = list[0]+x
    for i in range(1,n):
        #print "%r %r %r %r" % (i,list[i],pos,x)
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    return True

#print checkD(0)

low = 0.
high = 1000000000.
ans = -1.

loop = 0
while low + eps <= high and loop < 200 :
    mid = (low+high)/2.
    #print "low: %r mid %r high %r" % (low,mid,high)
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid
    loop+=1

print "%.11lf" % ans


__author__ = 'ckboss'

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-10

list = []
for x in numbers:
    list.append(float(x))

list.append(l)
n+=1
list = sorted(list)

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    for i in range(0,n):
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    return True

low = 0.
high = 1000000000.
ans = 0.

while low + eps <= high :
    mid = (low+high)/2.
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid

print "%.11lf" % ans


__author__ = 'ckboss'

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-9

list = []
for x in numbers:
    list.append(float(x))

list.append(l)
n+=1
list = sorted(list)

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    for i in range(0,n):
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    return True

low = 0.
high = 100000000.
ans = 0.

loop = 0
while low + eps <= high and loop < 100 :
    mid = (low+high)/2.
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid
    loop+=1

print "%.11lf" % ans


__author__ = 'ckboss'

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-9

list = []
for x in numbers:
    list.append(float(x))

list.append(l)
n+=1
list = sorted(list)

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    for i in range(0,n):
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    return True

low = 0.
high = 100000000.
ans = 0.

while low + eps <= high :
    mid = (low+high)/2.
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid

print "%.11lf" % ans


__author__ = 'ckboss'

import sys

n,l = raw_input().split(' ')
numbers = raw_input().split(' ')

n = int(n)
l = float(l)

eps = 1e-9

list = []
for x in numbers:
    list.append(float(x))

list = sorted(list)

if n == 1 :
    print max(list[0],l-list[0])
    sys.exit();

#print list

def checkD(x):
    pos = x
    if pos + eps < list[0]:
        return False
    pos = list[0]+x
    for i in range(1,n):
        #print "%r %r %r %r" % (i,list[i],pos,x)
        if pos + x + eps <= list[i]:
            return False
        pos = list[i]+x
    if list[n-1]+x + eps > l:
        return True
    else :
        return False

#print checkD(200)

low = 0.
high = 1000000000.
ans = -1.

loop = 0
while low + eps <= high and loop < 200 :
    mid = (low+high)/2.
    #print "low: %r mid %r high %r" % (low,mid,high)
    if checkD(mid) == True :
        high = mid
        ans = mid
    else :
        low = mid
    loop+=1

print "%.11lf" % ans


n, l = raw_input().split()
a = map( int, raw_input().split() )
a.append( 0 )
a.append( int( l ) )
a.sort()
ans = 0
for i in range( len( a ) - 1 ):
    ans = max( ans, a [ i + 1 ] - a[ i ] )
print 1.0 * ans / 2


n, l = raw_input().split()
a = map( int, raw_input().split() )
a.append(0)
a.append( int(l) )
a.sort()
ans = 0
for i in range(len(a) - 1):
    ans = max(a[i + 1]-a[i])
print 1.0 * ans / 2


n, l = raw_input().split()
a = map( int, raw_input().split() )
a.sort()
ans = max( a[ 0 ], int( l ) - a[ int( n ) - 1 ] )
for i in range( len( a ) - 1 ):
    ans = max( ans, a [ i + 1 ] - a[ i ] )
print 1.0 * ans / 2


n, l = raw_input().split()
a = map( int, raw_input().split() )
a.sort()
ans = max( a[ 0 ], int( l ) - a[ int( n ) - 1 ] ) * 2
for i in range( len( a ) - 1 ):
    ans = max( ans, a [ i + 1 ] - a[ i ] )
print 1.0 * ans / 2


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
b = a[::]
b.sort()
mxd = 0
if b[0]!=0:
    mxd = b[0]
if b[-1]!=l:
    q = l-b[-1]
    if mxd<q:
        mxd = q
i = 1
while i<n:
    q = (b[i]-b[i-1])/2.0
    if q>mxd:
        mxd = q
    i+=1
print '%.20f'%mxd


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
b = a[::]
b.sort()
mxd = 0
if b[0]!=0:
    mxd = b[0]
if b[-1]!=l:
    q = l-b[-1]
    if mxd<q:
        mxd = q
i = 1
while i<n:
    q = (b[i]-b[i-1])/2.0
    if q>mxd:
        mxd = q
    i+=1
print '%.10f'%mxd


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
b = a[::]
b.sort()
mxd = 0
if b[0]!=0:
    mxd = b[0]
if b[-1]!=l:
    q = l-b[-1]
    if mxd<q:
        mxd = q
i = 1
while i<n:
    q = (b[i]-b[i-1])/2.0
    if q>mxd:
        mxd = q
    i+=1
print '%.1020f'%mxd


import math
n,l=map(int,raw_input().split())
a=list(map(int,raw_input().split()))
d=0
a.sort()
for i in range(len(a)-1):
   d=max(d,abs(a[i]-a[i+1]))
d=d/2.0
if(a[0]!=0):
    d=max(d,a[0])
print  d


import math
n,l=map(int,raw_input().split())
a=list(map(int,raw_input().split()))
d=0
a.sort()
for i in range(len(a)-1):
   d=max(d,abs(a[i]-a[i+1]))
d=d/2.0
if(a[0]!=0):
    d=max(d,a[0])
if(a[len(a)-1]!=l):
    d=max((l-a[len(a)-1]),d)
print  d


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
initial = a[0]
final = l - a[n-1]
a[:] = [y-z for z,y in zip(a[:], a[1:])]
if(len(a)==0): print l
else:
 print max(final,initial, max(a[:])/2.0)


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
initial = a[0]
final = l - a[n-1]
a[:] = [y-z for z,y in zip(a[:], a[1:])]

print max(final,initial, max(a[:])/2.0)


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
initial = a[0]
final = l - a[n-1]
a[:] = [y-z for z,y in zip(a[:], a[1:])]
if(len(a)==0): print 1
else:
 print max(final,initial, max(a[:])/2.0)


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
initial = a[0]
final = l - a[n-1]
a[:] = [y-z for z,y in zip(a[:], a[1:])]
if(len(a)==0):
 print max(initial, final)
else:
 print max(final,initial, max(a[:])/2.0)


n,l = map(int, raw_input().split())
a = map(int, raw_input().split())
a.sort()
initial = a[0]
final = l - a[n-1]
a[:] = [y-z for z,y in zip(a[:], a[1:])]
print final,initial, max(a[:])
print max(final,initial, max(a[:])/2.0)


f = lambda: map(int, raw_input().split())
n, l = f()
arr = sorted(f())
minv = max([(b-a)/2.0 for (b, a) in zip([0]+arr, arr+[l])])
print max(minv, arr[0]-0, l-arr[-1])


f = lambda: map(int, raw_input())
n, l = f()
arr = sorted(f())
minv = min([(b-a)/2.0 for (b, a) in zip(arr, arr[1:])])
print min(minv, arr[0], l-arr[-1])


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mset(m,v) memset(m,v,sizeof(m))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pi 3.1415926535897932384
#define mod 1000000007
#define MAXM 1000000001

string s[1000100];
string s1[1000100];

int a[1000100],a1[1000100];

struct compare
{
   bool operator()(const int& l, const int& r)
   {
       return l > r;
   }
};

priority_queue<int,vector<int>, compare > pq;

int main()
{

    int n,i,j,k;

    cin>>n;

    for(i=0;i<n;i++){
        cin>>s[i];
        if(s[i]!="removeMin"){
            cin>>a[i];
        }else
            a[i]=-34433423;
    }

    int cnt=0;

    for(i=0;i<n;i++)
    {
        // cout<<"hello"<<endl;
        if(s[i]=="insert"){
            s1[cnt]="insert";
            a1[cnt++]=a[i];
            pq.push(a[i]);
        }
        else if(s[i]=="removeMin"){
            if(!pq.empty()){
                pq.pop();
            }
            else{
                s1[cnt]="insert";
                a1[cnt++]=2;
                pq.pop();
            }
            s1[cnt]="removeMin";
            a1[cnt++]=-34433423;
        }
        else{
            if(pq.empty()) {
                s1[cnt]="insert";
                a1[cnt++]=a[i];
                s1[cnt]=s[i];
                a1[cnt++]=a[i];
            }
            else{
                int x=pq.top();
                if(x==a[i])
                {
                    s1[cnt]=s[i];
                    a1[cnt++]=a[i];
                }
                else
                {
                    while(!pq.empty() && pq.top()<a[i]){
                        s1[cnt]="removeMin";
                        a1[cnt++]=-34433423;
                        pq.pop();
                    }
                    if(pq.top()>=a[i]){
                        s1[cnt]=s[i];
                        a1[cnt++]=a[i];
                    }
                    else{
                        s1[cnt]="insert";
                        a1[cnt++]=a[i];
                        s1[cnt]=s[i];
                        a1[cnt++]=a[i];
                        pq.push(a[i]);
                    }
                }
            }
        }
    }

    cout<<cnt<<endl;
    for(i=0;i<cnt;i++){
        cout<<s1[i];
        if(a1[i]!=-34433423)
            cout<<" "<<a1[i];
        cout<<endl;
    }

    return 0;
}