
// International Master sm0016
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define raftaar ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll MOD1=1000000007;

const ll MOD2= 998244353;

const int N=1e6+6;


int main(){
	raftaar
	
	int a,b;cin>>a>>b;int ans=1;int check[N]={0};

	for(int i=a;i<=b;i++){

		for(int j=1;j*j<=i;j++){

			if(i%j==0){

				if(j*j==i) check[j]++;

				else{check[j]++;check[i/j]++;}
			}
		}
	}
	for(int i=1;i<=max(a,b);i++){

		if(check[i]>1) ans=max(ans,i);
	}

	cout<<ans;
}

#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<ll,int>
#define PI 3.141592653589793
#define pb push_back
#define C complex<double>
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 998244353;

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	rep(i, n) cin >> a[i];
	rep(i, m) cin >> b[i];

	map<int, int> mp;
	rep(i, n) mp[a[i]]++;
	rep(i, m) mp[b[i]]++;
	rep(i, 1000) {
		if (mp[i + 1] == 1) cout << i + 1 << " ";
	}
}