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# (Mono 4.6.2.0) (judge verdict: Runtime Error)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace apc001b
{
    public class TwoArrays
    {
        List<int> a_, b_;

        public TwoArrays(string a, string b) {
            a_ = a.Split().ToList().ConvertAll(int.Parse);
            b_ = b.Split().ToList().ConvertAll(int.Parse);
        }

        private int Determine_i() {
            var maxDiffColumnNumber = 0;
            var maxDiff = b_[maxDiffColumnNumber] - a_[maxDiffColumnNumber]; ;
            for(var i = 1; i < a_.Count(); ++i) {
                var diff = b_[i] - a_[i];
                if(maxDiff < diff) {
                    maxDiff = diff;
                    maxDiffColumnNumber = i;
                }
            }
            return maxDiffColumnNumber;
        }

        private int Determine_j() {
            const int limitB = 1000000000;
            var minDiffColumnNumber = 0;
            var minDiff = b_[minDiffColumnNumber] - a_[minDiffColumnNumber];
            for(var j = 1; j < a_.Count(); ++j) {
                var diff = b_[j] - a_[j];
                if(diff < minDiff && b_[j]<limitB) {
                    minDiff = diff;
                    minDiffColumnNumber = j;
                }
            }
            return minDiffColumnNumber;
        }



        private void IncrementTwoArrays() {
            a_[Determine_i()] += 2;
            b_[Determine_j()]++;
        }

        public string Solve() {
            const int maxNumberOfTry = 10000;
            var numberOfTry = 0;
            var isAvailable = false;
            while(numberOfTry < maxNumberOfTry) {
                if(a_.Sum() > b_.Sum())
                    break;
                if(a_.SequenceEqual(b_)) {
                    isAvailable = true;
                    break;
                } else {
                    IncrementTwoArrays();
                    ++numberOfTry;
                }
            }
            return isAvailable ? "Yes" : "No";
        }
    }

    class Apc001b
    {
        static void Main(string[] args) {
            Console.ReadLine();
            var a = Console.ReadLine();
            var b = Console.ReadLine();
            var arrays = new TwoArrays(a, b);
            Console.WriteLine(arrays.Solve());
        }
    }
}