Problem:
Score : 100 points

Problem Statement

You are given positive integers X and Y.
If there exists a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, choose one such integer and print it.
If it does not exist, print -1.

Constraints

1 ≤ X,Y ≤ 10^9

X and Y are integers.

Input

Input is given from Standard Input in the following format:

X Y

Output

Print a positive integer not greater than 10^{18} that is a multiple of X but not a multiple of Y, or print -1 if it does not exist.

Sample Input 1

8 6

Sample Output 1

16

For example, 16 is a multiple of 8 but not a multiple of 6.

Sample Input 2

3 3

Sample Output 2

-1

A multiple of 3 is a multiple of 3.

Solution in C++14 (GCC 5.4.1) (judge verdict: Runtime Error)

//writer：Sakura
//problem：Antennas on Tree
//id：Petrozavodsk Contest 001--E
//from：AtCoder

#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <bits/stdc++.h>
#define inf 1000000007
#define N 100005
using namespace std;

typedef long long ll;

vector<ll> vec[N];
ll f[N][2];

void init(){
	for(int i=0;i<N;i++)f[1][0]=inf,f[i][1]=inf;
}

void dfs(ll now,ll par){
	ll t=0,nod=0,tmp=0;
	for(int i=0;i<vec[now].size();i++){
		if(vec[now][i]==par)continue;
		else{
			dfs(vec[now][i],now);
			t+=f[vec[now][i]][1];
			tmp++;
			nod=max(nod,f[vec[now][i]][1]-f[vec[now][i]][0]);
		}
	}
	f[now][0]=t-nod;
	if(tmp>2){
		f[now][1]=f[now][0];
	} 
	else{
		if(tmp==0){
			f[now][1]=1;
		}
		else{
			f[now][1]=t;
		}
	}
}
/**/


/*void dfs(ll now,ll par){
	ll t=0,nod=0,tmp=0;
	for(int i=0;i<vec[now].size();i++){
		if(vec[now][i]!=par){
			dfs(vec[now][i],now);
			t+=f[vec[now][i]][1];
			tmp++;
			nod=max(nod,f[vec[now][i]][1]-f[vec[now][i]][0]);
		}
		else continue;
	}
	f[now][0]=t-nod;
	if(tmp>=2)f[now][1]=f[now][0];
	else{
		if(tmp==0)f[now][1]=1;
		else f[now][1]=t;
	}
}
*/

int main(){
	//freopen("anrennas.in","r",stdin);
	//freopen("anrennas.out","w",stdout);
	int n;
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	init();
	ll id=0,ma=0;
	for(int i=0;i<n;i++){
		if(ma<vec[i].size()){
			ma=vec[i].size();
			id=i;
		}
	}
	dfs(id,-1);
	ll ans=1;
	ans=max(ans,f[id][0]);
	printf("%lld\n",ans);
	return 0;
}