function Main(input) {
  input = input.split(" ");
  var a = parseInt(input[0],10);
  var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);

  var as = Math.sqrt(a);
  var bs = Math.sqrt(b);
  var cs = Math.sqrt(c);

  if((as + bs) < cs) {
    console.log("Yes")
  } else {
    console.log("No")
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Global OOD problem IDs are disjoint from train, validation, and in-distribution test problem IDs.

Score : 300 points

Problem Statement

Does \sqrt{a} + \sqrt{b} < \sqrt{c} hold?

Constraints

1 \leq a, b, c \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

a \ b \ c

Output

If \sqrt{a} + \sqrt{b} < \sqrt{c}, print Yes; otherwise, print No.

Sample Input 1

2 3 9

Sample Output 1

No

\sqrt{2} + \sqrt{3} < \sqrt{9} does not hold.

Sample Input 2

2 3 10

Sample Output 2

Yes

\sqrt{2} + \sqrt{3} < \sqrt{10} holds.

Submitted source-code file size, in bytes.

Execution CPU time reported by official Project CodeNet metadata, in milliseconds.

Peak memory usage reported by official Project CodeNet metadata, in kilobytes.


function Main(input) {
  var a = parseInt(input[0],10);
  var b = parseInt(input[1], 10);
  var c = parseInt(input[2], 10);

  var as = Math.sqrt(a);
  var bs = Math.sqrt(b);
  var cs = Math.sqrt(c);

  if((as + bs) < cs) {
    console.log("Yes")
  } else {
    console.log("No")
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();
const line = input.split('\n')[0].split(' ');
const a = +line[0];
const b = +line[1];
const c = +line[2];

const d = c - a - b;

if (d > 0 && 4 * a * b < d * d) {
    console.log('Yes');
} else {
    console.log('No');
}


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var a = one[0];
  var b = one[1];
  var c = one[2];
  if(a >= c || b >= c){
     myout("No");
    return;
  }
  var ra = Math.sqrt(one[0]);
  var rb = Math.sqrt(one[1]);
  var rc = Math.sqrt(one[2]);
  if(Math.sqrt(a + b) < rc){
    myout("Yes");
  }else{
    myout("No");
  }

}


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/panasonic2020/C.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/panasonic2020/C.js":
/*!********************************!*\
  !*** ./src/panasonic2020/C.js ***!
  \********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\n\nvar NOT_FOUND = -1;\nvar INFINITE = 1001001001;\n\nvar main = function main(input) {\n  var _input$split$0$split$ = input.split('\\n')[0].split(' ').map(function (i) {\n    return i - 0;\n  }),\n      _input$split$0$split$2 = _slicedToArray(_input$split$0$split$, 3),\n      a = _input$split$0$split$2[0],\n      b = _input$split$0$split$2[1],\n      c = _input$split$0$split$2[2];\n\n  var answer = 0 < Math.sqrt(c) - Math.sqrt(b) - Math.sqrt(a);\n\n  if (answer) {\n    console.log('Yes');\n  } else {\n    console.log('No');\n  }\n};\n\nmain(fs.readFileSync('/dev/stdin', 'utf8'));\n\n//# sourceURL=webpack:///./src/panasonic2020/C.js?");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack:///external_%22fs%22?");

/***/ })

/******/ });


function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split(" ");
  const a = Number(input[0]);
  const b = Number(input[1]);
  const c = Number(input[2]);
  if (Math.sqrt(c) > Math.sqrt(a) + Math.sqrt(b)) {

    console.log("Yes");
  } else if (Math.sqrt(c) <= Math.sqrt(a) + Math.sqrt(b)) {
    console.log("No");
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const A = parseInt(arg[0].split(" ")[0]);
    const B = parseInt(arg[0].split(" ")[1]);
    const C = parseInt(arg[0].split(" ")[2]);

    let temp = Math.sqrt(A) + Math.sqrt(B);

    console.log(temp < Math.sqrt(C) ? "Yes" : "No")
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
a = l.shift() * 1
b = l.shift() * 1
c = l.shift() * 1
console.log(Math.sqrt(a)+Math.sqrt(b)<Math.sqrt(c) ? "Yes": "No")


"use strict";
const input = require("fs").readFileSync("/dev/stdin", "utf8").trim();
const line = input.split('\n')[0].split(' ');
const a = +line[0];
const b = +line[1];
const c = +line[2];
if (Math.sqrt(a) + Math.sqrt(b) < Math.sqrt(c)) {
    console.log('Yes');
} else {
    console.log('No');
}


const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }

  if (n.length > 1 && n[0] === 0) {
    console.log(-1)
    return
  }

  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = (i === 0 && N !== 1) ? 1 : 0
    }
  }
  console.log(n.join(''))

})()

Score : 300 points

Problem Statement

If there is an integer not less than 0 satisfying the following conditions, print the smallest such integer; otherwise, print -1.

The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.)

The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)

Constraints

All values in input are integers.

1 \leq N \leq 3

0 \leq M \leq 5

1 \leq s_i \leq N

0 \leq c_i \leq 9

Input

Input is given from Standard Input in the following format:

N M
s_1 c_1
\vdots
s_M c_M

Output

Print the answer.

Sample Input 1

3 3
1 7
3 2
1 7

Sample Output 1

702

702 satisfies the conditions - its 1-st and 3-rd digits are 7 and 2, respectively - while no non-negative integer less than 702 satisfies them.

Sample Input 2

3 2
2 1
2 3

Sample Output 2

-1

Sample Input 3

3 1
1 0

Sample Output 3

-1


const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')

const [N, M] = lines[0].split(' ').map(Number)
const s = []
const c = []

for (let i = 0; i < M; i++) {
  const row = lines[i + 1].split(' ').map(Number)
  s[i] = row[0] - 1
  c[i] = row[1]
}

;(() => {
  const n = Array(N).fill(null)
  for (let i = 0; i < M; i++) {
	if (n[s[i]] && n[s[i]] !== c[i]) {
      console.log(-1)
      return
    }
    n[s[i]] = c[i]
  }

  if (n[0] === 0) {
    console.log(-1)
    return
  }

  for (let i = 0; i < N; i++) {
    if (n[i] === null)  {
      n[i] = i === 0 ? 1 : 0
    }
  }
  console.log(n.join(''))

})()


"use strict";

const main = arg => {
    const input = arg.trim().split("\n");

    const N = parseInt(input[0].split(" ")[0]);
    const M = parseInt(input[0].split(" ")[1]);
    let s = {}
    for(let i = 1; i<=M; i++){
        let digit = parseInt(input[i].split(" ")[0])
        let num = parseInt(input[i].split(" ")[1])
        if(s[digit] && s[digit] !== num){
            console.log('-1')
            return
        } else if (digit === 1 && num == 0){
            console.log('-1')
            return
        } else {
            s[digit] = num
        }
    }
    let ans = new Array(N).fill(0)
    if(N==1){
        console.log(s[1] || 0)
        return
    }
    ans[0] = 1
    for(let key of Object.keys(s)){
        ans[key-1] = s[key]
    }
    console.log(Number(ans.join("")))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


(function Main(input){
	var input = input.split('\n'),
		_ = input[0].split(' '),
		N = Number(_[0]),
		M = Number(_[1]),
		arr = new Array(N),
		flag = true;

	input.splice(0,1);

	for(var i=0; i<M; i++){
		var _ = input[i].split(' '),
			s = _[0],
			c = _[1];

		if(arr[s-1] && arr[s-1] != c){ flag = false; break; }
		arr[s-1] = c;
	}

	if(N >= 2 && arr[0] === '0'){ flag = false; }

	if(flag){
		for(var i=0; i<arr.length; i++){
			if(!arr[0]){
				arr[0] = 1;

			}else if(!arr[i]){
				arr[i] = 0;
			}
		}
		console.log(arr.join(''));

	}else{
		console.log(-1);
	}
})(require("fs").readFileSync("/dev/stdin","utf8"));


process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

// 解答
function main(inputs){

    // 桁数
    var digit = Number(inputs[0].split(" ")[0]);
    // 入力した組み合わせ数
    var conv = Number(inputs[0].split(" ")[1]);
    // 選ばれた数値リスト
    var list = ['','',''];
    var answer = 0;

    // 各桁数の整数の指定がない場合
    if (conv == 0) {

        switch (digit) {
            case 2:
                answer = 10;
                break;
            case 3:
                answer = 100;
                break;
            default:
                break;
        }

        return console.log(answer);
    }

    // 入力値格納
    for (var i = 1; i < inputs.length; i++) {

        var tagetDigit = inputs[i].split(" ")[0] - 1;
        var num = inputs[i].split(" ")[1];

        // 同じ桁数で複数の数値が指定された場合、エラー
        if (list[tagetDigit] != '' && list[tagetDigit] != num) {

            return console.log(-1);
        }

        if (list[tagetDigit] == '') {

            list[tagetDigit] = num;
        }
    }

    for (var i = 0; i < digit; i++) {

        if (i === 0 && Number(list[i]) === 0) {

            return console.log(-1);
        }

        if (list[i] == '') {

            if (i === 0) {

                list[i] = 1;
            }

            if (i > 0) {

                list[i] = 0;
            }
        }
    }

    switch (digit) {
        case 3:
            answer = Number(list[0]) * 100
                   + Number(list[1]) * 10
                   + Number(list[2]);
            break;
        case 2:
            answer = Number(list[0] * 10)
                   + Number(list[1]);
            break;
        default:
            answer = Number(list[0]);
                break;

    }

    console.log(answer);
}


"use strict"
function Main(stdin){
stdin = stdin.trim().split("\n").reverse();
let stdout = [];
function input(){return stdin.pop()};
function maput(){return input().split(" ").map(n=>parseInt(n))};
function print(x){stdout.push(x)};
function exist(x, xs){return new Set(xs).has(x)}
function max(x){return x.reduce(function(a,b){ return Math.max(a,b) }) }
function min(x){return x.reduce(function(a,b){ return Math.min(a,b) }) }
function sum(x){return x.reduce(function(a,b){ return a+b }) }
function sorting(x, index){x.sort((a, b) => a[index] - b[index])}
function all(x){return x.reduce(function(a,b){ return a && b }) }
function any(x){return x.reduce(function(a,b){ return a || b }) }
function list(iterable){return Array.from(iterable)}
function vint(iterable){return Array.from(iterable, x => parseInt(x))}
function tile(val, len){return Array(len).fill(val)}
const range = (start, stop, step) => Array.from(
    { length: (stop - start) / step }, (_, i) => start + (i * step));
/*START*/

let nm = maput()
let n = nm[0]
let m = nm[1]
let a = new Array(m)
for (let i = 0; i < m; i++){ a[i] = input() }

let x = Math.pow(10, n-1)
let xmax = x * 10
if (n == 1){ x = 0 }
let ans = [-1]

while (x < xmax){

    let s = String(x)
    let b = new Array(m)
    for (let i = 0; i < m; i++){
        b[i] = (s[parseInt(a[i][0]) - 1] == a[i][2])
    }

    if (all(b)){
        ans.push(x)
        break
    }
    x++
}

print(ans[ans.length - 1])

/*
n,m = map(int, input().split())
a = [input() for _ in range(m)]

x = 10 ** (n - 1)
if n == 1: x = 0
ans = [-1]

while x < 10 ** n:
    s = str(x)
    if all(s[int(ai[0]) - 1] == ai[2] for ai in a):
        ans.append(x)
        break
    x += 1

print(ans[-1])
*/

/*END*/
console.log(stdout.join("\n"));
return stdout
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/ABC157/C.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/ABC157/C.js":
/*!*************************!*\
  !*** ./src/ABC157/C.js ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\n\nvar INCORRECT = -1;\n\nvar main = function main(input) {\n  var lines = input.split('\\n');\n\n  var _lines$shift$split$ma = lines.shift().split(' ').map(function (i) {\n    return i - 0;\n  }),\n      _lines$shift$split$ma2 = _slicedToArray(_lines$shift$split$ma, 2),\n      N = _lines$shift$split$ma2[0],\n      M = _lines$shift$split$ma2[1];\n\n  var p = [];\n\n  for (var i = 0; i < N; i++) {\n    p.push(0);\n  }\n\n  for (var _i2 = 0; _i2 < M; _i2++) {\n    var _lines$shift$split$ma3 = lines.shift().split(' ').map(function (i) {\n      return i - 0;\n    }),\n        _lines$shift$split$ma4 = _slicedToArray(_lines$shift$split$ma3, 2),\n        s = _lines$shift$split$ma4[0],\n        c = _lines$shift$split$ma4[1];\n\n    var column = s - 1;\n\n    if (p[column] === 0 || p[column] > c) {\n      p[column] = c;\n    }\n  }\n\n  if (p.length === 1) {\n    if (p[0] === 0) {\n      console.log(0);\n      return;\n    }\n  }\n\n  if (p.length === 2) {\n    if (p[0] === 0) {\n      console.log(INCORRECT);\n      return;\n    }\n  }\n\n  if (p.length === 3) {\n    if (p[0] === 0 && p[1] === 0) {\n      console.log(INCORRECT);\n      return;\n    }\n  }\n\n  var number = Number(p.reduce(function (acc, cur) {\n    return acc + cur;\n  }, ''));\n\n  if (Number.isNaN(number)) {\n    console.log(INCORRECT);\n  } else {\n    console.log(number);\n  }\n};\n\nmain(fs.readFileSync('/dev/stdin', 'utf8'));\n\n//# sourceURL=webpack:///./src/ABC157/C.js?");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack:///external_%22fs%22?");

/***/ })

/******/ });


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/ABC157/C.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/ABC157/C.js":
/*!*************************!*\
  !*** ./src/ABC157/C.js ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\n\nvar INCORRECT = -1;\n\nvar main = function main(input) {\n  var lines = input.split('\\n');\n\n  var _lines$shift$split$ma = lines.shift().split(' ').map(function (i) {\n    return i - 0;\n  }),\n      _lines$shift$split$ma2 = _slicedToArray(_lines$shift$split$ma, 2),\n      N = _lines$shift$split$ma2[0],\n      M = _lines$shift$split$ma2[1];\n\n  var p = [];\n\n  for (var i = 0; i < N; i++) {\n    p.push(0);\n  }\n\n  for (var _i2 = 0; _i2 < M; _i2++) {\n    var _lines$shift$split$ma3 = lines.shift().split(' ').map(function (i) {\n      return i - 0;\n    }),\n        _lines$shift$split$ma4 = _slicedToArray(_lines$shift$split$ma3, 2),\n        s = _lines$shift$split$ma4[0],\n        c = _lines$shift$split$ma4[1];\n\n    var column = s - 1;\n\n    if (p[column] === 0 || p[column] > c) {\n      p[column] = c;\n    }\n  }\n\n  if (p.length >= 2) {\n    if (p[0] === null || p[0] === 0) {\n      console.log(INCORRECT);\n      return;\n    }\n  }\n\n  var number = Number(p.reduce(function (acc, cur) {\n    return acc + cur;\n  }, ''));\n\n  if (Number.isNaN(number)) {\n    console.log(INCORRECT);\n  } else {\n    console.log(number);\n  }\n};\n\nmain(fs.readFileSync('/dev/stdin', 'utf8'));\n\n//# sourceURL=webpack:///./src/ABC157/C.js?");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack:///external_%22fs%22?");

/***/ })

/******/ });


/******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/ABC157/C.js");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./src/ABC157/C.js":
/*!*************************!*\
  !*** ./src/ABC157/C.js ***!
  \*************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

eval("function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }\n\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); }\n\nfunction _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === \"[object Arguments]\")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"] != null) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; }\n\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\n\nvar fs = __webpack_require__(/*! fs */ \"fs\");\n\nvar INCORRECT = -1;\n\nvar main = function main(input) {\n  var lines = input.split('\\n');\n\n  var _lines$shift$split$ma = lines.shift().split(' ').map(function (i) {\n    return i - 0;\n  }),\n      _lines$shift$split$ma2 = _slicedToArray(_lines$shift$split$ma, 2),\n      N = _lines$shift$split$ma2[0],\n      M = _lines$shift$split$ma2[1];\n\n  var p = [];\n\n  for (var i = 0; i < N; i++) {\n    p.push(null);\n  }\n\n  for (var _i2 = 0; _i2 < M; _i2++) {\n    var _lines$shift$split$ma3 = lines.shift().split(' ').map(function (i) {\n      return i - 0;\n    }),\n        _lines$shift$split$ma4 = _slicedToArray(_lines$shift$split$ma3, 2),\n        s = _lines$shift$split$ma4[0],\n        c = _lines$shift$split$ma4[1];\n\n    var column = s - 1;\n\n    if (p[column] === null || p[column] > c) {\n      p[column] = c;\n    }\n  }\n\n  if (p.length >= 2) {\n    if (p[0] === null || p[0] === 0) {\n      return console.log(INCORRECT);\n    }\n  }\n\n  for (var _i3 = 0, l = p.length; _i3 < l; _i3++) {\n    if (p[_i3] === null) {\n      p[_i3] = 0;\n    }\n  }\n\n  var number = Number(p.reduce(function (acc, cur) {\n    return acc + cur;\n  }, ''));\n\n  if (Number.isNaN(number)) {\n    console.log(INCORRECT);\n  } else {\n    console.log(number);\n  }\n};\n\nmain(fs.readFileSync('/dev/stdin', 'utf8'));\n\n//# sourceURL=webpack:///./src/ABC157/C.js?");

/***/ }),

/***/ "fs":
/*!*********************!*\
  !*** external "fs" ***!
  \*********************/
/*! no static exports found */
/***/ (function(module, exports) {

eval("module.exports = require(\"fs\");\n\n//# sourceURL=webpack:///external_%22fs%22?");

/***/ })

/******/ });


function Main(inputs) {
  var lines = inputs.split('\n');
  var N = lines[0].split(' ')[0];

  var flag = 0;
  var ns = Array.from({ length : N });

  lines.slice(1)
  .filter(v=>v != '')
  .forEach(line=>{
    var s = (+line.split(' ')[0]) - 1;
    var c = (+line.split(' ')[1]);

    if(ns[s] != null && ns[s] != c){
      flag = 1;
    }
    ns[s] = c
  })

  if(ns[0] == 0)    { flag = 1 }
  if(ns.length > N) { flag = 1 }

  var first = ns[0] == null ? 0 : ns[0];
  if(first == 0 && ns.length != 1) {first = 1}
  var n = [ first, ...ns.slice(1).map(v=> v || 0) ].join('');

  console.log(flag  == 0 ? n : -1)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


// inputに入力データ全体が入る
function Main(input) {
  input = input.split("\n");
  tmp = input.shift();
  N = parseInt(tmp.split(" ")[0]);
  M = tmp.split(" ")[1];
  S = input;
  A = "n".repeat(N).split("");
  flag = true;
  S.forEach(v => {
    t = v.split(" ").map(v => parseInt(v));
    if (A[t[0] - 1] != "n" && A[t[0] - 1] != t[1]) flag = false;
    A[t[0] - 1] = t[1];
  });

  A = A.join("");
  A = A.replace(/^nn([0-9])/, "10$1");
  A = A.replace(/^n([0-9])/, "1$1");
  A = A.replace(/n/g, "0");
  A = parseInt(A);
  if (flag && (A + "").length == N) {
    console.log(A);
  } else {
    console.log(-1);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


// inputに入力データ全体が入る
function Main(input) {
	ans = -1
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	N = input[0].split(' ').map((n) => (parseInt(n)))[0]
	f = input.slice(1)
	ansarr = new Array(N).fill(0)
	for (i = 0; i < f.length; i++) {
		var tmp = f[i].split(' ').map((n) => (parseInt(n)))
		ansarr[tmp[0] -1] = tmp[1]
	}
	var c = ansarr.join("")
	var d = parseInt(c).toString()
	if (c == d) {
		ans = parseInt(d)
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));


var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}

function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = myconv(next(),4);
  var N = one[0];
  var M = one[1];
  if(M == 0){
     if(N == 1){
        myout(0);
     }else{
        myout(-1);
     }
    return;
  }
  var slist = new Array();
  var clist = new Array();
  while(hasNext()){
    var tmp = myconv(next(),4);
    if(slist.indexOf(tmp[0]) != -1 && clist.indexOf(tmp[1]) != -1){
       continue;
    }
    slist.push(tmp[0]);
    clist.push(tmp[1]);
  }
  switch(N){
    case 1:
      myout(Math.min.apply(null,clist));
      break;
    case 2:
      var list = new Array(2);
      for(var i = 0; i < slist.length; i++){
        if(slist[i] == 1){
          if(clist[i] == 0){
             continue;
          }
          if(list[0] == null){
             list[0] = clist[i];
          }else{
             list[0] = Math.min(list[0],clist[i]);
          }
        }else{
          if(list[1] == null){
             list[1] = clist[i];
          }else{
             list[1] = Math.min(list[1],clist[i]);
          }
        }
      }
      if(list[0] == 0 || list[0] == null){
         myout(-1);
         return;
      }
      if(list[1] == null){
         list[1] = 0;
      }
      myout(myconv(list,0));
      break;
    case 3:
      myerr(slist);
      myerr(clist);
      var list = new Array(3);
      for(var i = 0; i < slist.length; i++){
        if(slist[i] == 1){
          if(clist[i] == 0){
             continue;
          }
          if(list[0] == null){
             list[0] = clist[i];
          }else{
             list[0] = Math.min(list[0],clist[i]);
          }
        }else if(slist[i] == 2){
          if(list[1] == null){
             list[1] = clist[i];
          }else{
             list[1] = Math.min(list[1],clist[i]);
          }
        }else{
          if(list[2] == null){
             list[2] = clist[i];
          }else{
             list[2] = Math.min(list[2],clist[i]);
          }

        }
      }
      if(list[0] == 0 || list[0] == null){
         myout(-1);
         return;
      }
      if(list[1] == null){
         list[1] = 0;
      }
      if(list[2] == null){
         list[2] = 0;
      }
      myout(myconv(list,0));
      break;
  }
}
Main();


function Main(input) {
    var N = parseInt(input[0].split(/\s/)[0], 10);
    var M = parseInt(input[0].split(/\s/)[1], 10);
    var s = input.slice(1).map(sc => sc.split(/\s/)[0]);
    var c = input.slice(1).map(sc => sc.split(/\s/)[1]);

    var list = new Array(N);
    list.fill(-1);

    for (var i = 0; i < M; i++) {
        if (list[s[i] - 1] !== -1 && list[s[i] - 1] !== c[i]) {
            return console.log(-1);
        } else {
            list[s[i] - 1] = c[i];
        }
    }

    var result = '';

    for (var j = 0; j < N; j++) {
        if (j === 0 && N !== 1) {
            if (list[j] === -1) {
                result += '1';
            } else if (list[j] === '0') {
                return console.log(-1);
            } else {
                result += `${list[j]}`;
            }
        } else if (list[j] === -1) {
            result += '0';
        } else {
            result += `${list[j]}`;
        }
    }

    console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim().split(/\n/));


"use strict";

const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    const sc = arg.slice(1, M + 1).map(n=>n.split(" "));

    let answer = new Array(N).fill("x");

    for(let i in sc) {
        let digit  = parseInt(sc[i][0]);
        let number = sc[i][1];

        // console.log("answer:" + answer);
        // console.log("a:" + answer[digit - 1]);
        // console.log(answer[digit - 1] !== "x");

        // すでに他の数字で確保されているのはNG
        if(answer[digit - 1] !== number && answer[digit - 1] !== "x") {
            console.log(-1);
            return;
        }

        answer[digit - 1] = number;
    }

    // 最小を考える
    for(let i in answer) {
        if(answer[answer.length - i] === "x") {
            answer[answer.length - i] = 0;
        }
    }

    if(answer[0] === "x") {
        answer[0] = 1;
    }

    console.log(String(parseInt(answer.join(""))).length === N ? answer.join("") : -1);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1
a = new Array(N)
b = true
for (i=0; i<M; i++) {
  l = inp.shift().split(' ')
  if (a[l[0] - 1] === undefined) {
      a[l[0] - 1] = l[1]
  } else if (a[l[0] - 1] != l[1]) {
      b = false
      break;
  }
}
if (b) {
    for (i=0; i<N; i++) {
        if (i === 0 && a[i] === undefined && M > 1) {
            a[i] = 1
            continue;
        }
        if (a[i] === undefined) {
            a[i] = 0
        }
    }
    ans = a.join("") * 1
    if (a.join("") == ans && N == (ans + "").length) {
        b = true
    } else {
        b = false
    }
}
console.log(b ? ans : -1)


inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
M = l.shift() * 1
a = new Array(N)
b = true
for (i=0; i<M; i++) {
  l = inp.shift().split(' ')
  if (a[l[0] - 1] === undefined) {
      a[l[0] - 1] = l[1]
  } else if (a[l[0] - 1] != l[1]) {
      b = false
      break;
  }
}
if (M === 0) {
    b = false
} else if (b) {
    for (i=0; i<N; i++) {
        if (i === 0 && a[i] === undefined) {
            a[i] = 1
            continue;
        }
        if (a[i] === undefined) {
            a[i] = 0
        }
    }
    ans = a.join("") * 1
    if (a.join("") == ans && N == (ans + "").length) {
        ans = a.join("") * 1
        b = true
    } else {
        b = false
    }
}
console.log(b ? ans : -1)


/*!
 * path: atcoder/abc155/d
 * URL: https://github.com/koukimetal/procomvis/tree/master/src/contest/atcoder/abc155/d
 */!function(t){var e={};function r(o){if(e[o])return e[o].exports;var n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=e,r.d=function(t,e,o){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(r.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(o,n,function(e){return t[e]}.bind(null,n));return o},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var o=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var n=o(r(1)),i=r(2);n.default.readFile("/dev/stdin","utf8",(function(t,e){!function(t){var e=new i.Solver,r=e.parse(t),o=e.solve(r);e.print(o)}(e)}))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var o,n=this&&this.__extends||(o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)},function(t,e){function r(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),i=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};e.__esModule=!0;var u=r(3),a=r(4),p=i(r(5)),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.solve=function(t){var e=t.N,r=t.K,o=t.A;o.sort((function(t,e){return t-e}));for(var n=new Array(e),i=0;i<e;i++)n[i]=p.default(o[i]);var u=0,a=0,s=0;for(i=0;i<e;i++)o[i]<0?u++:o[i]>0?a++:s++;for(var l=u*a,f=s*(a+u)+s*(s-1)/2,v=p.default(2),c=p.default("-1000000000000000005"),h=p.default("1000000000000000005");h.minus(c).gt(p.default.one);){var y=h.plus(c).divide(v),g=0;if(y.lt(p.default.zero))for(i=0;i<e&&!(o[i]>=0);i++){for(var d=u+s-1,m=e;m-d>1;){var b=(d+m)/2|0;n[i].multiply(n[b]).lt(y)?m=b:d=b}g+=e-m}else if(y.gt(p.default.zero)){g+=l+f;for(i=0;i<e;i++)if(o[i]<0){for(d=i,m=u;m-d>1;){b=(d+m)/2|0;n[i].multiply(n[b]).lt(y)?m=b:d=b}g+=u-m}else if(o[i]>0){for(d=i,m=e;m-d>1;){b=(d+m)/2|0;n[i].multiply(n[b]).lt(y)?d=b:m=b}g+=d-i}}else g=l;g<r?c=y:h=y}return{answer:c}},e.prototype.parse=function(t){for(var e=a.getSpaceIterator(t,(function(t){return parseInt(t)})),r=e.next().value,o=e.next().value,n=[],i=0;i<r;i++)n.push(e.next().value);return{N:r,K:o,A:n}},e.prototype.print=function(t){console.log(t.answer.toString())},e}(u.SolverBase);e.Solver=s},function(t,e,r){"use strict";e.__esModule=!0;var o=function(){};e.SolverBase=o},function(t,e,r){"use strict";var o=this&&this.__generator||function(t,e){var r,o,n,i,u={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;u;)try{if(r=1,o&&(n=2&i[0]?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,o=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(n=(n=u.trys).length>0&&n[n.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){u.label=i[1];break}if(6===i[0]&&u.label<n[1]){u.label=n[1],n=i;break}if(n&&u.label<n[2]){u.label=n[2],u.ops.push(i);break}n[2]&&u.ops.pop(),u.trys.pop();continue}i=e.call(t,u)}catch(t){i=[6,t],o=0}finally{r=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}};e.__esModule=!0,e.getSpaceIterator=function(t,e){var r,n;return o(this,(function(o){switch(o.label){case 0:r=0,n=t.split(/\s+/).map((function(t){return e(t)})),o.label=1;case 1:return r<n.length?[4,n[r]]:[3,4];case 2:o.sent(),o.label=3;case 3:return r++,[3,1];case 4:return[2,void 0]}}))}},function(t,e,r){(function(t){var o,n=function(t){"use strict";var e=9007199254740992,r=l(e),o="function"==typeof BigInt;function i(t,e,r,o){return void 0===t?i[0]:void 0!==e&&(10!=+e||r)?U(t,e,r,o):K(t)}function u(t,e){this.value=t,this.sign=e,this.isSmall=!1}function a(t){this.value=t,this.sign=t<0,this.isSmall=!0}function p(t){this.value=t}function s(t){return-e<t&&t<e}function l(t){return t<1e7?[t]:t<1e14?[t%1e7,Math.floor(t/1e7)]:[t%1e7,Math.floor(t/1e7)%1e7,Math.floor(t/1e14)]}function f(t){v(t);var e=t.length;if(e<4&&_(t,r)<0)switch(e){case 0:return 0;case 1:return t[0];case 2:return t[0]+1e7*t[1];default:return t[0]+1e7*(t[1]+1e7*t[2])}return t}function v(t){for(var e=t.length;0===t[--e];);t.length=e+1}function c(t){for(var e=new Array(t),r=-1;++r<t;)e[r]=0;return e}function h(t){return t>0?Math.floor(t):Math.ceil(t)}function y(t,e){var r,o,n=t.length,i=e.length,u=new Array(n),a=0;for(o=0;o<i;o++)a=(r=t[o]+e[o]+a)>=1e7?1:0,u[o]=r-1e7*a;for(;o<n;)a=1e7===(r=t[o]+a)?1:0,u[o++]=r-1e7*a;return a>0&&u.push(a),u}function g(t,e){return t.length>=e.length?y(t,e):y(e,t)}function d(t,e){var r,o,n=t.length,i=new Array(n);for(o=0;o<n;o++)r=t[o]-1e7+e,e=Math.floor(r/1e7),i[o]=r-1e7*e,e+=1;for(;e>0;)i[o++]=e%1e7,e=Math.floor(e/1e7);return i}function m(t,e){var r,o,n=t.length,i=e.length,u=new Array(n),a=0;for(r=0;r<i;r++)(o=t[r]-a-e[r])<0?(o+=1e7,a=1):a=0,u[r]=o;for(r=i;r<n;r++){if(!((o=t[r]-a)<0)){u[r++]=o;break}o+=1e7,u[r]=o}for(;r<n;r++)u[r]=t[r];return v(u),u}function b(t,e,r){var o,n,i=t.length,p=new Array(i),s=-e;for(o=0;o<i;o++)n=t[o]+s,s=Math.floor(n/1e7),n%=1e7,p[o]=n<0?n+1e7:n;return"number"==typeof(p=f(p))?(r&&(p=-p),new a(p)):new u(p,r)}function w(t,e){var r,o,n,i,u=t.length,a=e.length,p=c(u+a);for(n=0;n<u;++n){i=t[n];for(var s=0;s<a;++s)r=i*e[s]+p[n+s],o=Math.floor(r/1e7),p[n+s]=r-1e7*o,p[n+s+1]+=o}return v(p),p}function S(t,e){var r,o,n=t.length,i=new Array(n),u=0;for(o=0;o<n;o++)r=t[o]*e+u,u=Math.floor(r/1e7),i[o]=r-1e7*u;for(;u>0;)i[o++]=u%1e7,u=Math.floor(u/1e7);return i}function M(t,e){for(var r=[];e-- >0;)r.push(0);return r.concat(t)}function q(t,e,r){return new u(t<1e7?S(e,t):w(e,l(t)),r)}function N(t){var e,r,o,n,i=t.length,u=c(i+i);for(o=0;o<i;o++){r=0-(n=t[o])*n;for(var a=o;a<i;a++)e=n*t[a]*2+u[o+a]+r,r=Math.floor(e/1e7),u[o+a]=e-1e7*r;u[o+i]=r}return v(u),u}function O(t,e){var r,o,n,i,u=t.length,a=c(u);for(n=0,r=u-1;r>=0;--r)n=(i=1e7*n+t[r])-(o=h(i/e))*e,a[r]=0|o;return[a,0|n]}function E(t,e){var r,n=K(e);if(o)return[new p(t.value/n.value),new p(t.value%n.value)];var s,y=t.value,g=n.value;if(0===g)throw new Error("Cannot divide by zero");if(t.isSmall)return n.isSmall?[new a(h(y/g)),new a(y%g)]:[i[0],t];if(n.isSmall){if(1===g)return[t,i[0]];if(-1==g)return[t.negate(),i[0]];var d=Math.abs(g);if(d<1e7){s=f((r=O(y,d))[0]);var b=r[1];return t.sign&&(b=-b),"number"==typeof s?(t.sign!==n.sign&&(s=-s),[new a(s),new a(b)]):[new u(s,t.sign!==n.sign),new a(b)]}g=l(d)}var w=_(y,g);if(-1===w)return[i[0],t];if(0===w)return[i[t.sign===n.sign?1:-1],i[0]];s=(r=y.length+g.length<=200?function(t,e){var r,o,n,i,u,a,p,s=t.length,l=e.length,v=c(e.length),h=e[l-1],y=Math.ceil(1e7/(2*h)),g=S(t,y),d=S(e,y);for(g.length<=s&&g.push(0),d.push(0),h=d[l-1],o=s-l;o>=0;o--){for(r=1e7-1,g[o+l]!==h&&(r=Math.floor((1e7*g[o+l]+g[o+l-1])/h)),n=0,i=0,a=d.length,u=0;u<a;u++)n+=r*d[u],p=Math.floor(n/1e7),i+=g[o+u]-(n-1e7*p),n=p,i<0?(g[o+u]=i+1e7,i=-1):(g[o+u]=i,i=0);for(;0!==i;){for(r-=1,n=0,u=0;u<a;u++)(n+=g[o+u]-1e7+d[u])<0?(g[o+u]=n+1e7,n=0):(g[o+u]=n,n=1);i+=n}v[o]=r}return g=O(g,y)[0],[f(v),f(g)]}(y,g):function(t,e){for(var r,o,n,i,u,a=t.length,p=e.length,s=[],l=[];a;)if(l.unshift(t[--a]),v(l),_(l,e)<0)s.push(0);else{n=1e7*l[(o=l.length)-1]+l[o-2],i=1e7*e[p-1]+e[p-2],o>p&&(n=1e7*(n+1)),r=Math.ceil(n/i);do{if(_(u=S(e,r),l)<=0)break;r--}while(r);s.push(r),l=m(l,u)}return s.reverse(),[f(s),f(l)]}(y,g))[0];var M=t.sign!==n.sign,q=r[1],N=t.sign;return"number"==typeof s?(M&&(s=-s),s=new a(s)):s=new u(s,M),"number"==typeof q?(N&&(q=-q),q=new a(q)):q=new u(q,N),[s,q]}function _(t,e){if(t.length!==e.length)return t.length>e.length?1:-1;for(var r=t.length-1;r>=0;r--)if(t[r]!==e[r])return t[r]>e[r]?1:-1;return 0}function P(t){var e=t.abs();return!e.isUnit()&&(!!(e.equals(2)||e.equals(3)||e.equals(5))||!(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))&&(!!e.lesser(49)||void 0))}function x(t,e){for(var r,o,i,u=t.prev(),a=u,p=0;a.isEven();)a=a.divide(2),p++;t:for(o=0;o<e.length;o++)if(!t.lesser(e[o])&&!(i=n(e[o]).modPow(a,t)).isUnit()&&!i.equals(u)){for(r=p-1;0!=r;r--){if((i=i.square().mod(t)).isUnit())return!1;if(i.equals(u))continue t}return!1}return!0}u.prototype=Object.create(i.prototype),a.prototype=Object.create(i.prototype),p.prototype=Object.create(i.prototype),u.prototype.add=function(t){var e=K(t);if(this.sign!==e.sign)return this.subtract(e.negate());var r=this.value,o=e.value;return e.isSmall?new u(d(r,Math.abs(o)),this.sign):new u(g(r,o),this.sign)},u.prototype.plus=u.prototype.add,a.prototype.add=function(t){var e=K(t),r=this.value;if(r<0!==e.sign)return this.subtract(e.negate());var o=e.value;if(e.isSmall){if(s(r+o))return new a(r+o);o=l(Math.abs(o))}return new u(d(o,Math.abs(r)),r<0)},a.prototype.plus=a.prototype.add,p.prototype.add=function(t){return new p(this.value+K(t).value)},p.prototype.plus=p.prototype.add,u.prototype.subtract=function(t){var e=K(t);if(this.sign!==e.sign)return this.add(e.negate());var r=this.value,o=e.value;return e.isSmall?b(r,Math.abs(o),this.sign):function(t,e,r){var o;return _(t,e)>=0?o=m(t,e):(o=m(e,t),r=!r),"number"==typeof(o=f(o))?(r&&(o=-o),new a(o)):new u(o,r)}(r,o,this.sign)},u.prototype.minus=u.prototype.subtract,a.prototype.subtract=function(t){var e=K(t),r=this.value;if(r<0!==e.sign)return this.add(e.negate());var o=e.value;return e.isSmall?new a(r-o):b(o,Math.abs(r),r>=0)},a.prototype.minus=a.prototype.subtract,p.prototype.subtract=function(t){return new p(this.value-K(t).value)},p.prototype.minus=p.prototype.subtract,u.prototype.negate=function(){return new u(this.value,!this.sign)},a.prototype.negate=function(){var t=this.sign,e=new a(-this.value);return e.sign=!t,e},p.prototype.negate=function(){return new p(-this.value)},u.prototype.abs=function(){return new u(this.value,!1)},a.prototype.abs=function(){return new a(Math.abs(this.value))},p.prototype.abs=function(){return new p(this.value>=0?this.value:-this.value)},u.prototype.multiply=function(t){var e,r,o,n=K(t),a=this.value,p=n.value,s=this.sign!==n.sign;if(n.isSmall){if(0===p)return i[0];if(1===p)return this;if(-1===p)return this.negate();if((e=Math.abs(p))<1e7)return new u(S(a,e),s);p=l(e)}return r=a.length,o=p.length,new u(-.012*r-.012*o+15e-6*r*o>0?function t(e,r){var o=Math.max(e.length,r.length);if(o<=30)return w(e,r);o=Math.ceil(o/2);var n=e.slice(o),i=e.slice(0,o),u=r.slice(o),a=r.slice(0,o),p=t(i,a),s=t(n,u),l=t(g(i,n),g(a,u)),f=g(g(p,M(m(m(l,p),s),o)),M(s,2*o));return v(f),f}(a,p):w(a,p),s)},u.prototype.times=u.prototype.multiply,a.prototype._multiplyBySmall=function(t){return s(t.value*this.value)?new a(t.value*this.value):q(Math.abs(t.value),l(Math.abs(this.value)),this.sign!==t.sign)},u.prototype._multiplyBySmall=function(t){return 0===t.value?i[0]:1===t.value?this:-1===t.value?this.negate():q(Math.abs(t.value),this.value,this.sign!==t.sign)},a.prototype.multiply=function(t){return K(t)._multiplyBySmall(this)},a.prototype.times=a.prototype.multiply,p.prototype.multiply=function(t){return new p(this.value*K(t).value)},p.prototype.times=p.prototype.multiply,u.prototype.square=function(){return new u(N(this.value),!1)},a.prototype.square=function(){var t=this.value*this.value;return s(t)?new a(t):new u(N(l(Math.abs(this.value))),!1)},p.prototype.square=function(t){return new p(this.value*this.value)},u.prototype.divmod=function(t){var e=E(this,t);return{quotient:e[0],remainder:e[1]}},p.prototype.divmod=a.prototype.divmod=u.prototype.divmod,u.prototype.divide=function(t){return E(this,t)[0]},p.prototype.over=p.prototype.divide=function(t){return new p(this.value/K(t).value)},a.prototype.over=a.prototype.divide=u.prototype.over=u.prototype.divide,u.prototype.mod=function(t){return E(this,t)[1]},p.prototype.mod=p.prototype.remainder=function(t){return new p(this.value%K(t).value)},a.prototype.remainder=a.prototype.mod=u.prototype.remainder=u.prototype.mod,u.prototype.pow=function(t){var e,r,o,n=K(t),u=this.value,p=n.value;if(0===p)return i[1];if(0===u)return i[0];if(1===u)return i[1];if(-1===u)return n.isEven()?i[1]:i[-1];if(n.sign)return i[0];if(!n.isSmall)throw new Error("The exponent "+n.toString()+" is too large.");if(this.isSmall&&s(e=Math.pow(u,p)))return new a(h(e));for(r=this,o=i[1];!0&p&&(o=o.times(r),--p),0!==p;)p/=2,r=r.square();return o},a.prototype.pow=u.prototype.pow,p.prototype.pow=function(t){var e=K(t),r=this.value,o=e.value,n=BigInt(0),u=BigInt(1),a=BigInt(2);if(o===n)return i[1];if(r===n)return i[0];if(r===u)return i[1];if(r===BigInt(-1))return e.isEven()?i[1]:i[-1];if(e.isNegative())return new p(n);for(var s=this,l=i[1];(o&u)===u&&(l=l.times(s),--o),o!==n;)o/=a,s=s.square();return l},u.prototype.modPow=function(t,e){if(t=K(t),(e=K(e)).isZero())throw new Error("Cannot take modPow with modulus 0");var r=i[1],o=this.mod(e);for(t.isNegative()&&(t=t.multiply(i[-1]),o=o.modInv(e));t.isPositive();){if(o.isZero())return i[0];t.isOdd()&&(r=r.multiply(o).mod(e)),t=t.divide(2),o=o.square().mod(e)}return r},p.prototype.modPow=a.prototype.modPow=u.prototype.modPow,u.prototype.compareAbs=function(t){var e=K(t),r=this.value,o=e.value;return e.isSmall?1:_(r,o)},a.prototype.compareAbs=function(t){var e=K(t),r=Math.abs(this.value),o=e.value;return e.isSmall?r===(o=Math.abs(o))?0:r>o?1:-1:-1},p.prototype.compareAbs=function(t){var e=this.value,r=K(t).value;return(e=e>=0?e:-e)===(r=r>=0?r:-r)?0:e>r?1:-1},u.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=K(t),r=this.value,o=e.value;return this.sign!==e.sign?e.sign?1:-1:e.isSmall?this.sign?-1:1:_(r,o)*(this.sign?-1:1)},u.prototype.compareTo=u.prototype.compare,a.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=K(t),r=this.value,o=e.value;return e.isSmall?r==o?0:r>o?1:-1:r<0!==e.sign?r<0?-1:1:r<0?1:-1},a.prototype.compareTo=a.prototype.compare,p.prototype.compare=function(t){if(t===1/0)return-1;if(t===-1/0)return 1;var e=this.value,r=K(t).value;return e===r?0:e>r?1:-1},p.prototype.compareTo=p.prototype.compare,u.prototype.equals=function(t){return 0===this.compare(t)},p.prototype.eq=p.prototype.equals=a.prototype.eq=a.prototype.equals=u.prototype.eq=u.prototype.equals,u.prototype.notEquals=function(t){return 0!==this.compare(t)},p.prototype.neq=p.prototype.notEquals=a.prototype.neq=a.prototype.notEquals=u.prototype.neq=u.prototype.notEquals,u.prototype.greater=function(t){return this.compare(t)>0},p.prototype.gt=p.prototype.greater=a.prototype.gt=a.prototype.greater=u.prototype.gt=u.prototype.greater,u.prototype.lesser=function(t){return this.compare(t)<0},p.prototype.lt=p.prototype.lesser=a.prototype.lt=a.prototype.lesser=u.prototype.lt=u.prototype.lesser,u.prototype.greaterOrEquals=function(t){return this.compare(t)>=0},p.prototype.geq=p.prototype.greaterOrEquals=a.prototype.geq=a.prototype.greaterOrEquals=u.prototype.geq=u.prototype.greaterOrEquals,u.prototype.lesserOrEquals=function(t){return this.compare(t)<=0},p.prototype.leq=p.prototype.lesserOrEquals=a.prototype.leq=a.prototype.lesserOrEquals=u.prototype.leq=u.prototype.lesserOrEquals,u.prototype.isEven=function(){return 0==(1&this.value[0])},a.prototype.isEven=function(){return 0==(1&this.value)},p.prototype.isEven=function(){return(this.value&BigInt(1))===BigInt(0)},u.prototype.isOdd=function(){return 1==(1&this.value[0])},a.prototype.isOdd=function(){return 1==(1&this.value)},p.prototype.isOdd=function(){return(this.value&BigInt(1))===BigInt(1)},u.prototype.isPositive=function(){return!this.sign},a.prototype.isPositive=function(){return this.value>0},p.prototype.isPositive=a.prototype.isPositive,u.prototype.isNegative=function(){return this.sign},a.prototype.isNegative=function(){return this.value<0},p.prototype.isNegative=a.prototype.isNegative,u.prototype.isUnit=function(){return!1},a.prototype.isUnit=function(){return 1===Math.abs(this.value)},p.prototype.isUnit=function(){return this.abs().value===BigInt(1)},u.prototype.isZero=function(){return!1},a.prototype.isZero=function(){return 0===this.value},p.prototype.isZero=function(){return this.value===BigInt(0)},u.prototype.isDivisibleBy=function(t){var e=K(t);return!e.isZero()&&(!!e.isUnit()||(0===e.compareAbs(2)?this.isEven():this.mod(e).isZero()))},p.prototype.isDivisibleBy=a.prototype.isDivisibleBy=u.prototype.isDivisibleBy,u.prototype.isPrime=function(t){var e=P(this);if(void 0!==e)return e;var r=this.abs(),o=r.bitLength();if(o<=64)return x(r,[2,3,5,7,11,13,17,19,23,29,31,37]);for(var i=Math.log(2)*o.toJSNumber(),u=Math.ceil(!0===t?2*Math.pow(i,2):i),a=[],p=0;p<u;p++)a.push(n(p+2));return x(r,a)},p.prototype.isPrime=a.prototype.isPrime=u.prototype.isPrime,u.prototype.isProbablePrime=function(t,e){var r=P(this);if(void 0!==r)return r;for(var o=this.abs(),i=void 0===t?5:t,u=[],a=0;a<i;a++)u.push(n.randBetween(2,o.minus(2),e));return x(o,u)},p.prototype.isProbablePrime=a.prototype.isProbablePrime=u.prototype.isProbablePrime,u.prototype.modInv=function(t){for(var e,r,o,i=n.zero,u=n.one,a=K(t),p=this.abs();!p.isZero();)e=a.divide(p),r=i,o=a,i=u,a=p,u=r.subtract(e.multiply(u)),p=o.subtract(e.multiply(p));if(!a.isUnit())throw new Error(this.toString()+" and "+t.toString()+" are not co-prime");return-1===i.compare(0)&&(i=i.add(t)),this.isNegative()?i.negate():i},p.prototype.modInv=a.prototype.modInv=u.prototype.modInv,u.prototype.next=function(){var t=this.value;return this.sign?b(t,1,this.sign):new u(d(t,1),this.sign)},a.prototype.next=function(){var t=this.value;return t+1<e?new a(t+1):new u(r,!1)},p.prototype.next=function(){return new p(this.value+BigInt(1))},u.prototype.prev=function(){var t=this.value;return this.sign?new u(d(t,1),!0):b(t,1,this.sign)},a.prototype.prev=function(){var t=this.value;return t-1>-e?new a(t-1):new u(r,!0)},p.prototype.prev=function(){return new p(this.value-BigInt(1))};for(var I=[1];2*I[I.length-1]<=1e7;)I.push(2*I[I.length-1]);var B=I.length,A=I[B-1];function j(t){return Math.abs(t)<=1e7}function Z(t,e,r){e=K(e);for(var o=t.isNegative(),i=e.isNegative(),u=o?t.not():t,a=i?e.not():e,p=0,s=0,l=null,f=null,v=[];!u.isZero()||!a.isZero();)p=(l=E(u,A))[1].toJSNumber(),o&&(p=A-1-p),s=(f=E(a,A))[1].toJSNumber(),i&&(s=A-1-s),u=l[0],a=f[0],v.push(r(p,s));for(var c=0!==r(o?1:0,i?1:0)?n(-1):n(0),h=v.length-1;h>=0;h-=1)c=c.multiply(A).add(n(v[h]));return c}u.prototype.shiftLeft=function(t){var e=K(t).toJSNumber();if(!j(e))throw new Error(String(e)+" is too large for shifting.");if(e<0)return this.shiftRight(-e);var r=this;if(r.isZero())return r;for(;e>=B;)r=r.multiply(A),e-=B-1;return r.multiply(I[e])},p.prototype.shiftLeft=a.prototype.shiftLeft=u.prototype.shiftLeft,u.prototype.shiftRight=function(t){var e,r=K(t).toJSNumber();if(!j(r))throw new Error(String(r)+" is too large for shifting.");if(r<0)return this.shiftLeft(-r);for(var o=this;r>=B;){if(o.isZero()||o.isNegative()&&o.isUnit())return o;o=(e=E(o,A))[1].isNegative()?e[0].prev():e[0],r-=B-1}return(e=E(o,I[r]))[1].isNegative()?e[0].prev():e[0]},p.prototype.shiftRight=a.prototype.shiftRight=u.prototype.shiftRight,u.prototype.not=function(){return this.negate().prev()},p.prototype.not=a.prototype.not=u.prototype.not,u.prototype.and=function(t){return Z(this,t,(function(t,e){return t&e}))},p.prototype.and=a.prototype.and=u.prototype.and,u.prototype.or=function(t){return Z(this,t,(function(t,e){return t|e}))},p.prototype.or=a.prototype.or=u.prototype.or,u.prototype.xor=function(t){return Z(this,t,(function(t,e){return t^e}))},p.prototype.xor=a.prototype.xor=u.prototype.xor;function J(t){var e=t.value,r="number"==typeof e?e|1<<30:"bigint"==typeof e?e|BigInt(1<<30):e[0]+1e7*e[1]|1073758208;return r&-r}function L(t,e){return t=K(t),e=K(e),t.greater(e)?t:e}function k(t,e){return t=K(t),e=K(e),t.lesser(e)?t:e}function T(t,e){if(t=K(t).abs(),e=K(e).abs(),t.equals(e))return t;if(t.isZero())return e;if(e.isZero())return t;for(var r,o,n=i[1];t.isEven()&&e.isEven();)r=k(J(t),J(e)),t=t.divide(r),e=e.divide(r),n=n.multiply(r);for(;t.isEven();)t=t.divide(J(t));do{for(;e.isEven();)e=e.divide(J(e));t.greater(e)&&(o=e,e=t,t=o),e=e.subtract(t)}while(!e.isZero());return n.isUnit()?t:t.multiply(n)}u.prototype.bitLength=function(){var t=this;return t.compareTo(n(0))<0&&(t=t.negate().subtract(n(1))),0===t.compareTo(n(0))?n(0):n(function t(e,r){if(r.compareTo(e)<=0){var o=t(e,r.square(r)),i=o.p,u=o.e,a=i.multiply(r);return a.compareTo(e)<=0?{p:a,e:2*u+1}:{p:i,e:2*u}}return{p:n(1),e:0}}(t,n(2)).e).add(n(1))},p.prototype.bitLength=a.prototype.bitLength=u.prototype.bitLength;var U=function(t,e,r,o){r=r||"0123456789abcdefghijklmnopqrstuvwxyz",t=String(t),o||(t=t.toLowerCase(),r=r.toLowerCase());var n,i=t.length,u=Math.abs(e),a={};for(n=0;n<r.length;n++)a[r[n]]=n;for(n=0;n<i;n++){if("-"!==(l=t[n])&&(l in a&&a[l]>=u)){if("1"===l&&1===u)continue;throw new Error(l+" is not a valid digit in base "+e+".")}}e=K(e);var p=[],s="-"===t[0];for(n=s?1:0;n<t.length;n++){var l;if((l=t[n])in a)p.push(K(a[l]));else{if("<"!==l)throw new Error(l+" is not a valid character");var f=n;do{n++}while(">"!==t[n]&&n<t.length);p.push(K(t.slice(f+1,n)))}}return z(p,e,s)};function z(t,e,r){var o,n=i[0],u=i[1];for(o=t.length-1;o>=0;o--)n=n.add(t[o].times(u)),u=u.times(e);return r?n.negate():n}function D(t,e){if((e=n(e)).isZero()){if(t.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(e.equals(-1)){if(t.isZero())return{value:[0],isNegative:!1};if(t.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-t.toJSNumber())).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(t.toJSNumber()-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var o=!1;if(t.isNegative()&&e.isPositive()&&(o=!0,t=t.abs()),e.isUnit())return t.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(t.toJSNumber())).map(Number.prototype.valueOf,1),isNegative:o};for(var i,u=[],a=t;a.isNegative()||a.compareAbs(e)>=0;){i=a.divmod(e),a=i.quotient;var p=i.remainder;p.isNegative()&&(p=e.minus(p).abs(),a=a.next()),u.push(p.toJSNumber())}return u.push(a.toJSNumber()),{value:u.reverse(),isNegative:o}}function C(t,e,r){var o=D(t,e);return(o.isNegative?"-":"")+o.value.map((function(t){return function(t,e){return t<(e=e||"0123456789abcdefghijklmnopqrstuvwxyz").length?e[t]:"<"+t+">"}(t,r)})).join("")}function R(t){if(s(+t)){var e=+t;if(e===h(e))return o?new p(BigInt(e)):new a(e);throw new Error("Invalid integer: "+t)}var r="-"===t[0];r&&(t=t.slice(1));var n=t.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==h(i)||!s(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var l=n[0],f=l.indexOf(".");if(f>=0&&(i-=l.length-f-1,l=l.slice(0,f)+l.slice(f+1)),i<0)throw new Error("Cannot include negative exponent part for integers");t=l+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(t))throw new Error("Invalid integer: "+t);if(o)return new p(BigInt(r?"-"+t:t));for(var c=[],y=t.length,g=y-7;y>0;)c.push(+t.slice(g,y)),(g-=7)<0&&(g=0),y-=7;return v(c),new u(c,r)}function K(t){return"number"==typeof t?function(t){if(o)return new p(BigInt(t));if(s(t)){if(t!==h(t))throw new Error(t+" is not an integer.");return new a(t)}return R(t.toString())}(t):"string"==typeof t?R(t):"bigint"==typeof t?new p(t):t}u.prototype.toArray=function(t){return D(this,t)},a.prototype.toArray=function(t){return D(this,t)},p.prototype.toArray=function(t){return D(this,t)},u.prototype.toString=function(t,e){if(void 0===t&&(t=10),10!==t)return C(this,t,e);for(var r,o=this.value,n=o.length,i=String(o[--n]);--n>=0;)r=String(o[n]),i+="0000000".slice(r.length)+r;return(this.sign?"-":"")+i},a.prototype.toString=function(t,e){return void 0===t&&(t=10),10!=t?C(this,t,e):String(this.value)},p.prototype.toString=a.prototype.toString,p.prototype.toJSON=u.prototype.toJSON=a.prototype.toJSON=function(){return this.toString()},u.prototype.valueOf=function(){return parseInt(this.toString(),10)},u.prototype.toJSNumber=u.prototype.valueOf,a.prototype.valueOf=function(){return this.value},a.prototype.toJSNumber=a.prototype.valueOf,p.prototype.valueOf=p.prototype.toJSNumber=function(){return parseInt(this.toString(),10)};for(var F=0;F<1e3;F++)i[F]=K(F),F>0&&(i[-F]=K(-F));return i.one=i[1],i.zero=i[0],i.minusOne=i[-1],i.max=L,i.min=k,i.gcd=T,i.lcm=function(t,e){return t=K(t).abs(),e=K(e).abs(),t.divide(T(t,e)).multiply(e)},i.isInstance=function(t){return t instanceof u||t instanceof a||t instanceof p},i.randBetween=function(t,e,r){t=K(t),e=K(e);var o=r||Math.random,n=k(t,e),u=L(t,e).subtract(n).add(1);if(u.isSmall)return n.add(Math.floor(o()*u));for(var a=D(u,1e7).value,p=[],s=!0,l=0;l<a.length;l++){var f=s?a[l]:1e7,v=h(o()*f);p.push(v),v<f&&(s=!1)}return n.add(i.fromArray(p,1e7,!1))},i.fromArray=function(t,e,r){return z(t.map(K),K(e||10),r)},i}();t.hasOwnProperty("exports")&&(t.exports=n),void 0===(o=function(){return n}.call(e,r,e,t))||(t.exports=o)}).call(this,r(6)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}}]);

Score: 400 points

Problem Statement

We have N integers A_1, A_2, ..., A_N.

There are \frac{N(N-1)}{2} ways to choose two of them and form a pair. If we compute the product of each of those pairs and sort the results in ascending order, what will be the K-th number in that list?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq K \leq \frac{N(N-1)}{2}

-10^9 \leq A_i \leq 10^9\ (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.

Sample Input 1

4 3
3 3 -4 -2

Sample Output 1

-6

There are six ways to form a pair. The products of those pairs are 9, -12, -6, -12, -6, 8.

Sorting those numbers in ascending order, we have -12, -12, -6, -6, 8, 9. The third number in this list is -6.

Sample Input 2

10 40
5 4 3 2 -1 0 0 0 0 0

Sample Output 2

6

Sample Input 3

30 413
-170202098 -268409015 537203564 983211703 21608710 -443999067 -937727165 -97596546 -372334013 398994917 -972141167 798607104 -949068442 -959948616 37909651 0 886627544 -20098238 0 -948955241 0 -214720580 277222296 -18897162 834475626 0 -425610555 110117526 663621752 0

Sample Output 3

448283280358331064


/*!
 * path: atcoder/abc155/d
 * URL: https://github.com/koukimetal/procomvis/tree/master/src/contest/atcoder/abc155/d
 */!function(e){var r={};function n(t){if(r[t])return r[t].exports;var i=r[t]={i:t,l:!1,exports:{}};return e[t].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var i in e)n.d(t,i,function(r){return e[r]}.bind(null,i));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=0)}([function(e,r,n){"use strict";var t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};r.__esModule=!0;var i=t(n(1)),o=n(2);i.default.readFile("/dev/stdin","utf8",(function(e,r){!function(e){var r=new o.Solver,n=r.parse(e),t=r.solve(n);r.print(t)}(r)}))},function(e,r){e.exports=require("fs")},function(e,r,n){"use strict";var t,i=this&&this.__extends||(t=function(e,r){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var n in r)r.hasOwnProperty(n)&&(e[n]=r[n])})(e,r)},function(e,r){function n(){this.constructor=e}t(e,r),e.prototype=null===r?Object.create(r):(n.prototype=r.prototype,new n)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var r,n=1,t=arguments.length;n<t;n++)for(var i in r=arguments[n])Object.prototype.hasOwnProperty.call(r,i)&&(e[i]=r[i]);return e}).apply(this,arguments)},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};r.__esModule=!0;var s=n(3),f=n(4),l=u(n(5)),c=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return i(r,e),r.prototype.mul=function(e,r){var n=new l.default(e),t=new l.default(r);return n.multipliedBy(t)},r.prototype.solve=function(e){var r=e.N,n=e.K,t=e.A,i=new Array(r);t.sort((function(e,r){return Math.abs(e)-Math.abs(r)})),i[r-1]={pos:0,neg:0,zer:0};for(var u=r-2;u>=0;u--){var s=i[u+1];i[u]=o({},s),t[u+1]>0?i[u].pos++:t[u+1]<0?i[u].neg++:i[u].zer++}var f=new Array(r);for(u=0;u<r;u++)f[u]={pos:0,neg:0,zer:0},0===t[u]?f[u].zer=r-u-1:t[u]>0?(f[u].pos=i[u].pos,f[u].neg=i[u].neg):(f[u].pos=i[u].neg,f[u].neg=i[u].pos);var l=f.reduce((function(e,r){return e+r.neg}),0),c=f.reduce((function(e,r){return e+r.zer}),0);if(n<=l){var a=n;for(u=r-1;u>=0;u--)if(a<=f[u].neg){for(var h=t[u]<0?-1:1,p=r-1;p>u;p--)if(h*t[p]<0&&a--,0===a)return{answer:this.mul(t[p],t[u])}}else a-=f[u].neg}else{if(n<=l+c)return{answer:this.mul(0,1)};for(a=n-l-c,u=0;u<r;u++)if(a<=f[u].pos){for(h=t[u]<0?-1:1,p=u+1;p<r;p++)if(h*t[p]>0&&a--,0===a)return{answer:this.mul(t[p],t[u])}}else a-=f[u].pos}return{answer:this.mul(111,1)}},r.prototype.parse=function(e){for(var r=f.getSpaceIterator(e,(function(e){return parseInt(e)})),n=r.next().value,t=r.next().value,i=[],o=0;o<n;o++)i.push(r.next().value);return{N:n,K:t,A:i}},r.prototype.print=function(e){console.log(e.answer.toString())},r}(s.SolverBase);r.Solver=c},function(e,r,n){"use strict";r.__esModule=!0;var t=function(){};r.SolverBase=t},function(e,r,n){"use strict";var t=this&&this.__generator||function(e,r){var n,t,i,o,u={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;u;)try{if(n=1,t&&(i=2&o[0]?t.return:o[0]?t.throw||((i=t.return)&&i.call(t),0):t.next)&&!(i=i.call(t,o[1])).done)return i;switch(t=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,t=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(!(i=(i=u.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){u=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){u.label=o[1];break}if(6===o[0]&&u.label<i[1]){u.label=i[1],i=o;break}if(i&&u.label<i[2]){u.label=i[2],u.ops.push(o);break}i[2]&&u.ops.pop(),u.trys.pop();continue}o=r.call(e,u)}catch(e){o=[6,e],t=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};r.__esModule=!0,r.getSpaceIterator=function(e,r){var n,i;return t(this,(function(t){switch(t.label){case 0:n=0,i=e.split(/\s+/).map((function(e){return r(e)})),t.label=1;case 1:return n<i.length?[4,i[n]]:[3,4];case 2:t.sent(),t.label=3;case 3:return n++,[3,1];case 4:return[2,void 0]}}))}},function(e,r,n){"use strict";n.r(r),n.d(r,"BigNumber",(function(){return w}));var t=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,o=Math.floor,u="[BigNumber Error] ",s=u+"Number primitive has more than 15 significant digits: ",f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13];function l(e){var r=0|e;return e>0||e===r?r:r-1}function c(e){for(var r,n,t=1,i=e.length,o=e[0]+"";t<i;){for(n=14-(r=e[t++]+"").length;n--;r="0"+r);o+=r}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function a(e,r){var n,t,i=e.c,o=r.c,u=e.s,s=r.s,f=e.e,l=r.e;if(!u||!s)return null;if(n=i&&!i[0],t=o&&!o[0],n||t)return n?t?0:-s:u;if(u!=s)return u;if(n=u<0,t=f==l,!i||!o)return t?0:!i^n?1:-1;if(!t)return f>l^n?1:-1;for(s=(f=i.length)<(l=o.length)?f:l,u=0;u<s;u++)if(i[u]!=o[u])return i[u]>o[u]^n?1:-1;return f==l?0:f>l^n?1:-1}function h(e,r,n,t){if(e<r||e>n||e!==o(e))throw Error(u+(t||"Argument")+("number"==typeof e?e<r||e>n?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function p(e){var r=e.c.length-1;return l(e.e/14)==r&&e.c[r]%2!=0}function g(e,r){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(r<0?"e":"e+")+r}function d(e,r,n){var t,i;if(r<0){for(i=n+".";++r;i+=n);e=i+e}else if(++r>(t=e.length)){for(i=n,r-=t;--r;i+=n);e+=i}else r<t&&(e=e.slice(0,r)+"."+e.slice(r));return e}var w=function e(r){var n,w,v,m,y,b,O,_,N,E=j.prototype={constructor:j,toString:null,valueOf:null},A=new j(1),S=20,x=4,P=-7,M=21,B=-1e7,D=1e7,R=!1,I=1,T=0,L={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},U="0123456789abcdefghijklmnopqrstuvwxyz";function j(e,r){var n,i,u,f,l,c,a,p,g=this;if(!(g instanceof j))return new j(e,r);if(null==r){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>D?g.c=g.e=null:e.e<B?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((c="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(f=0,l=e;l>=10;l/=10,f++);return void(f>D?g.c=g.e=null:(g.e=f,g.c=[e]))}p=String(e)}else{if(!t.test(p=String(e)))return v(g,p,c);g.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(f=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(f<0&&(f=l),f+=+p.slice(l+1),p=p.substring(0,l)):f<0&&(f=p.length)}else{if(h(r,2,U.length,"Base"),10==r)return F(g=new j(e),S+g.e+1,x);if(p=String(e),c="number"==typeof e){if(0*e!=0)return v(g,p,c,r);if(g.s=1/e<0?(p=p.slice(1),-1):1,j.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(s+e)}else g.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(n=U.slice(0,r),f=l=0,a=p.length;l<a;l++)if(n.indexOf(i=p.charAt(l))<0){if("."==i){if(l>f){f=a;continue}}else if(!u&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){u=!0,l=-1,f=0;continue}return v(g,String(e),c,r)}c=!1,(f=(p=w(p,r,10,g.s)).indexOf("."))>-1?p=p.replace(".",""):f=p.length}for(l=0;48===p.charCodeAt(l);l++);for(a=p.length;48===p.charCodeAt(--a););if(p=p.slice(l,++a)){if(a-=l,c&&j.DEBUG&&a>15&&(e>9007199254740991||e!==o(e)))throw Error(s+g.s*e);if((f=f-l-1)>D)g.c=g.e=null;else if(f<B)g.c=[g.e=0];else{if(g.e=f,g.c=[],l=(f+1)%14,f<0&&(l+=14),l<a){for(l&&g.c.push(+p.slice(0,l)),a-=14;l<a;)g.c.push(+p.slice(l,l+=14));l=14-(p=p.slice(l)).length}else l-=a;for(;l--;p+="0");g.c.push(+p)}}else g.c=[g.e=0]}function C(e,r,n,t){var i,o,u,s,f;if(null==n?n=x:h(n,0,8),!e.c)return e.toString();if(i=e.c[0],u=e.e,null==r)f=c(e.c),f=1==t||2==t&&(u<=P||u>=M)?g(f,u):d(f,u,"0");else if(o=(e=F(new j(e),r,n)).e,s=(f=c(e.c)).length,1==t||2==t&&(r<=o||o<=P)){for(;s<r;f+="0",s++);f=g(f,o)}else if(r-=u,f=d(f,o,"0"),o+1>s){if(--r>0)for(f+=".";r--;f+="0");}else if((r+=o-s)>0)for(o+1==s&&(f+=".");r--;f+="0");return e.s<0&&i?"-"+f:f}function k(e,r){for(var n,t=1,i=new j(e[0]);t<e.length;t++){if(!(n=new j(e[t])).s){i=n;break}r.call(i,n)&&(i=n)}return i}function G(e,r,n){for(var t=1,i=r.length;!r[--i];r.pop());for(i=r[0];i>=10;i/=10,t++);return(n=t+14*n-1)>D?e.c=e.e=null:n<B?e.c=[e.e=0]:(e.e=n,e.c=r),e}function F(e,r,n,t){var u,s,l,c,a,h,p,g=e.c,d=f;if(g){e:{for(u=1,c=g[0];c>=10;c/=10,u++);if((s=r-u)<0)s+=14,l=r,p=(a=g[h=0])/d[u-l-1]%10|0;else if((h=i((s+1)/14))>=g.length){if(!t)break e;for(;g.length<=h;g.push(0));a=p=0,u=1,l=(s%=14)-14+1}else{for(a=c=g[h],u=1;c>=10;c/=10,u++);p=(l=(s%=14)-14+u)<0?0:a/d[u-l-1]%10|0}if(t=t||r<0||null!=g[h+1]||(l<0?a:a%d[u-l-1]),t=n<4?(p||t)&&(0==n||n==(e.s<0?3:2)):p>5||5==p&&(4==n||t||6==n&&(s>0?l>0?a/d[u-l]:0:g[h-1])%10&1||n==(e.s<0?8:7)),r<1||!g[0])return g.length=0,t?(r-=e.e+1,g[0]=d[(14-r%14)%14],e.e=-r||0):g[0]=e.e=0,e;if(0==s?(g.length=h,c=1,h--):(g.length=h+1,c=d[14-s],g[h]=l>0?o(a/d[u-l]%d[l])*c:0),t)for(;;){if(0==h){for(s=1,l=g[0];l>=10;l/=10,s++);for(l=g[0]+=c,c=1;l>=10;l/=10,c++);s!=c&&(e.e++,1e14==g[0]&&(g[0]=1));break}if(g[h]+=c,1e14!=g[h])break;g[h--]=0,c=1}for(s=g.length;0===g[--s];g.pop());}e.e>D?e.c=e.e=null:e.e<B&&(e.c=[e.e=0])}return e}function z(e){var r,n=e.e;return null===n?e.toString():(r=c(e.c),r=n<=P||n>=M?g(r,n):d(r,n,"0"),e.s<0?"-"+r:r)}return j.clone=e,j.ROUND_UP=0,j.ROUND_DOWN=1,j.ROUND_CEIL=2,j.ROUND_FLOOR=3,j.ROUND_HALF_UP=4,j.ROUND_HALF_DOWN=5,j.ROUND_HALF_EVEN=6,j.ROUND_HALF_CEIL=7,j.ROUND_HALF_FLOOR=8,j.EUCLID=9,j.config=j.set=function(e){var r,n;if(null!=e){if("object"!=typeof e)throw Error(u+"Object expected: "+e);if(e.hasOwnProperty(r="DECIMAL_PLACES")&&(h(n=e[r],0,1e9,r),S=n),e.hasOwnProperty(r="ROUNDING_MODE")&&(h(n=e[r],0,8,r),x=n),e.hasOwnProperty(r="EXPONENTIAL_AT")&&((n=e[r])&&n.pop?(h(n[0],-1e9,0,r),h(n[1],0,1e9,r),P=n[0],M=n[1]):(h(n,-1e9,1e9,r),P=-(M=n<0?-n:n))),e.hasOwnProperty(r="RANGE"))if((n=e[r])&&n.pop)h(n[0],-1e9,-1,r),h(n[1],1,1e9,r),B=n[0],D=n[1];else{if(h(n,-1e9,1e9,r),!n)throw Error(u+r+" cannot be zero: "+n);B=-(D=n<0?-n:n)}if(e.hasOwnProperty(r="CRYPTO")){if((n=e[r])!==!!n)throw Error(u+r+" not true or false: "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw R=!n,Error(u+"crypto unavailable");R=n}else R=n}if(e.hasOwnProperty(r="MODULO_MODE")&&(h(n=e[r],0,9,r),I=n),e.hasOwnProperty(r="POW_PRECISION")&&(h(n=e[r],0,1e9,r),T=n),e.hasOwnProperty(r="FORMAT")){if("object"!=typeof(n=e[r]))throw Error(u+r+" not an object: "+n);L=n}if(e.hasOwnProperty(r="ALPHABET")){if("string"!=typeof(n=e[r])||/^.$|[+-.\s]|(.).*\1/.test(n))throw Error(u+r+" invalid: "+n);U=n}}return{DECIMAL_PLACES:S,ROUNDING_MODE:x,EXPONENTIAL_AT:[P,M],RANGE:[B,D],CRYPTO:R,MODULO_MODE:I,POW_PRECISION:T,FORMAT:L,ALPHABET:U}},j.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!j.DEBUG)return!0;var r,n,t=e.c,i=e.e,s=e.s;e:if("[object Array]"=={}.toString.call(t)){if((1===s||-1===s)&&i>=-1e9&&i<=1e9&&i===o(i)){if(0===t[0]){if(0===i&&1===t.length)return!0;break e}if((r=(i+1)%14)<1&&(r+=14),String(t[0]).length==r){for(r=0;r<t.length;r++)if((n=t[r])<0||n>=1e14||n!==o(n))break e;if(0!==n)return!0}}}else if(null===t&&null===i&&(null===s||1===s||-1===s))return!0;throw Error(u+"Invalid BigNumber: "+e)},j.maximum=j.max=function(){return k(arguments,E.lt)},j.minimum=j.min=function(){return k(arguments,E.gt)},j.random=(m=9007199254740992*Math.random()&2097151?function(){return o(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var r,n,t,s,l,c=0,a=[],p=new j(A);if(null==e?e=S:h(e,0,1e9),s=i(e/14),R)if(crypto.getRandomValues){for(r=crypto.getRandomValues(new Uint32Array(s*=2));c<s;)(l=131072*r[c]+(r[c+1]>>>11))>=9e15?(n=crypto.getRandomValues(new Uint32Array(2)),r[c]=n[0],r[c+1]=n[1]):(a.push(l%1e14),c+=2);c=s/2}else{if(!crypto.randomBytes)throw R=!1,Error(u+"crypto unavailable");for(r=crypto.randomBytes(s*=7);c<s;)(l=281474976710656*(31&r[c])+1099511627776*r[c+1]+4294967296*r[c+2]+16777216*r[c+3]+(r[c+4]<<16)+(r[c+5]<<8)+r[c+6])>=9e15?crypto.randomBytes(7).copy(r,c):(a.push(l%1e14),c+=7);c=s/7}if(!R)for(;c<s;)(l=m())<9e15&&(a[c++]=l%1e14);for(e%=14,(s=a[--c])&&e&&(l=f[14-e],a[c]=o(s/l)*l);0===a[c];a.pop(),c--);if(c<0)a=[t=0];else{for(t=-1;0===a[0];a.splice(0,1),t-=14);for(c=1,l=a[0];l>=10;l/=10,c++);c<14&&(t-=14-c)}return p.e=t,p.c=a,p}),j.sum=function(){for(var e=1,r=arguments,n=new j(r[0]);e<r.length;)n=n.plus(r[e++]);return n},w=function(){function e(e,r,n,t){for(var i,o,u=[0],s=0,f=e.length;s<f;){for(o=u.length;o--;u[o]*=r);for(u[0]+=t.indexOf(e.charAt(s++)),i=0;i<u.length;i++)u[i]>n-1&&(null==u[i+1]&&(u[i+1]=0),u[i+1]+=u[i]/n|0,u[i]%=n)}return u.reverse()}return function(r,t,i,o,u){var s,f,l,a,h,p,g,w,v=r.indexOf("."),m=S,y=x;for(v>=0&&(a=T,T=0,r=r.replace(".",""),p=(w=new j(t)).pow(r.length-v),T=a,w.c=e(d(c(p.c),p.e,"0"),10,i,"0123456789"),w.e=w.c.length),l=a=(g=e(r,t,i,u?(s=U,"0123456789"):(s="0123456789",U))).length;0==g[--a];g.pop());if(!g[0])return s.charAt(0);if(v<0?--l:(p.c=g,p.e=l,p.s=o,g=(p=n(p,w,m,y,i)).c,h=p.r,l=p.e),v=g[f=l+m+1],a=i/2,h=h||f<0||null!=g[f+1],h=y<4?(null!=v||h)&&(0==y||y==(p.s<0?3:2)):v>a||v==a&&(4==y||h||6==y&&1&g[f-1]||y==(p.s<0?8:7)),f<1||!g[0])r=h?d(s.charAt(1),-m,s.charAt(0)):s.charAt(0);else{if(g.length=f,h)for(--i;++g[--f]>i;)g[f]=0,f||(++l,g=[1].concat(g));for(a=g.length;!g[--a];);for(v=0,r="";v<=a;r+=s.charAt(g[v++]));r=d(r,l,s.charAt(0))}return r}}(),n=function(){function e(e,r,n){var t,i,o,u,s=0,f=e.length,l=r%1e7,c=r/1e7|0;for(e=e.slice();f--;)s=((i=l*(o=e[f]%1e7)+(t=c*o+(u=e[f]/1e7|0)*l)%1e7*1e7+s)/n|0)+(t/1e7|0)+c*u,e[f]=i%n;return s&&(e=[s].concat(e)),e}function r(e,r,n,t){var i,o;if(n!=t)o=n>t?1:-1;else for(i=o=0;i<n;i++)if(e[i]!=r[i]){o=e[i]>r[i]?1:-1;break}return o}function n(e,r,n,t){for(var i=0;n--;)e[n]-=i,i=e[n]<r[n]?1:0,e[n]=i*t+e[n]-r[n];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(t,i,u,s,f){var c,a,h,p,g,d,w,v,m,y,b,O,_,N,E,A,S,x=t.s==i.s?1:-1,P=t.c,M=i.c;if(!(P&&P[0]&&M&&M[0]))return new j(t.s&&i.s&&(P?!M||P[0]!=M[0]:M)?P&&0==P[0]||!M?0*x:x/0:NaN);for(m=(v=new j(x)).c=[],x=u+(a=t.e-i.e)+1,f||(f=1e14,a=l(t.e/14)-l(i.e/14),x=x/14|0),h=0;M[h]==(P[h]||0);h++);if(M[h]>(P[h]||0)&&a--,x<0)m.push(1),p=!0;else{for(N=P.length,A=M.length,h=0,x+=2,(g=o(f/(M[0]+1)))>1&&(M=e(M,g,f),P=e(P,g,f),A=M.length,N=P.length),_=A,b=(y=P.slice(0,A)).length;b<A;y[b++]=0);S=M.slice(),S=[0].concat(S),E=M[0],M[1]>=f/2&&E++;do{if(g=0,(c=r(M,y,A,b))<0){if(O=y[0],A!=b&&(O=O*f+(y[1]||0)),(g=o(O/E))>1)for(g>=f&&(g=f-1),w=(d=e(M,g,f)).length,b=y.length;1==r(d,y,w,b);)g--,n(d,A<w?S:M,w,f),w=d.length,c=1;else 0==g&&(c=g=1),w=(d=M.slice()).length;if(w<b&&(d=[0].concat(d)),n(y,d,b,f),b=y.length,-1==c)for(;r(M,y,A,b)<1;)g++,n(y,A<b?S:M,b,f),b=y.length}else 0===c&&(g++,y=[0]);m[h++]=g,y[0]?y[b++]=P[_]||0:(y=[P[_]],b=1)}while((_++<N||null!=y[0])&&x--);p=null!=y[0],m[0]||m.splice(0,1)}if(1e14==f){for(h=1,x=m[0];x>=10;x/=10,h++);F(v,u+(v.e=h+14*a-1)+1,s,p)}else v.e=a,v.r=+p;return v}}(),y=/^(-?)0([xbo])(?=\w[\w.]*$)/i,b=/^([^.]+)\.$/,O=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,N=/^\s*\+(?=[\w.])|^\s+|\s+$/g,v=function(e,r,n,t){var i,o=n?r:r.replace(N,"");if(_.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!n&&(o=o.replace(y,(function(e,r,n){return i="x"==(n=n.toLowerCase())?16:"b"==n?2:8,t&&t!=i?e:r})),t&&(i=t,o=o.replace(b,"$1").replace(O,"0.$1")),r!=o))return new j(o,i);if(j.DEBUG)throw Error(u+"Not a"+(t?" base "+t:"")+" number: "+r);e.s=null}e.c=e.e=null},E.absoluteValue=E.abs=function(){var e=new j(this);return e.s<0&&(e.s=1),e},E.comparedTo=function(e,r){return a(this,new j(e,r))},E.decimalPlaces=E.dp=function(e,r){var n,t,i,o=this;if(null!=e)return h(e,0,1e9),null==r?r=x:h(r,0,8),F(new j(o),e+o.e+1,r);if(!(n=o.c))return null;if(t=14*((i=n.length-1)-l(this.e/14)),i=n[i])for(;i%10==0;i/=10,t--);return t<0&&(t=0),t},E.dividedBy=E.div=function(e,r){return n(this,new j(e,r),S,x)},E.dividedToIntegerBy=E.idiv=function(e,r){return n(this,new j(e,r),0,1)},E.exponentiatedBy=E.pow=function(e,r){var n,t,s,f,l,c,a,h,g=this;if((e=new j(e)).c&&!e.isInteger())throw Error(u+"Exponent not an integer: "+z(e));if(null!=r&&(r=new j(r)),l=e.e>14,!g.c||!g.c[0]||1==g.c[0]&&!g.e&&1==g.c.length||!e.c||!e.c[0])return h=new j(Math.pow(+z(g),l?2-p(e):+z(e))),r?h.mod(r):h;if(c=e.s<0,r){if(r.c?!r.c[0]:!r.s)return new j(NaN);(t=!c&&g.isInteger()&&r.isInteger())&&(g=g.mod(r))}else{if(e.e>9&&(g.e>0||g.e<-1||(0==g.e?g.c[0]>1||l&&g.c[1]>=24e7:g.c[0]<8e13||l&&g.c[0]<=9999975e7)))return f=g.s<0&&p(e)?-0:0,g.e>-1&&(f=1/f),new j(c?1/f:f);T&&(f=i(T/14+2))}for(l?(n=new j(.5),c&&(e.s=1),a=p(e)):a=(s=Math.abs(+z(e)))%2,h=new j(A);;){if(a){if(!(h=h.times(g)).c)break;f?h.c.length>f&&(h.c.length=f):t&&(h=h.mod(r))}if(s){if(0===(s=o(s/2)))break;a=s%2}else if(F(e=e.times(n),e.e+1,1),e.e>14)a=p(e);else{if(0===(s=+z(e)))break;a=s%2}g=g.times(g),f?g.c&&g.c.length>f&&(g.c.length=f):t&&(g=g.mod(r))}return t?h:(c&&(h=A.div(h)),r?h.mod(r):f?F(h,T,x,void 0):h)},E.integerValue=function(e){var r=new j(this);return null==e?e=x:h(e,0,8),F(r,r.e+1,e)},E.isEqualTo=E.eq=function(e,r){return 0===a(this,new j(e,r))},E.isFinite=function(){return!!this.c},E.isGreaterThan=E.gt=function(e,r){return a(this,new j(e,r))>0},E.isGreaterThanOrEqualTo=E.gte=function(e,r){return 1===(r=a(this,new j(e,r)))||0===r},E.isInteger=function(){return!!this.c&&l(this.e/14)>this.c.length-2},E.isLessThan=E.lt=function(e,r){return a(this,new j(e,r))<0},E.isLessThanOrEqualTo=E.lte=function(e,r){return-1===(r=a(this,new j(e,r)))||0===r},E.isNaN=function(){return!this.s},E.isNegative=function(){return this.s<0},E.isPositive=function(){return this.s>0},E.isZero=function(){return!!this.c&&0==this.c[0]},E.minus=function(e,r){var n,t,i,o,u=this,s=u.s;if(r=(e=new j(e,r)).s,!s||!r)return new j(NaN);if(s!=r)return e.s=-r,u.plus(e);var f=u.e/14,c=e.e/14,a=u.c,h=e.c;if(!f||!c){if(!a||!h)return a?(e.s=-r,e):new j(h?u:NaN);if(!a[0]||!h[0])return h[0]?(e.s=-r,e):new j(a[0]?u:3==x?-0:0)}if(f=l(f),c=l(c),a=a.slice(),s=f-c){for((o=s<0)?(s=-s,i=a):(c=f,i=h),i.reverse(),r=s;r--;i.push(0));i.reverse()}else for(t=(o=(s=a.length)<(r=h.length))?s:r,s=r=0;r<t;r++)if(a[r]!=h[r]){o=a[r]<h[r];break}if(o&&(i=a,a=h,h=i,e.s=-e.s),(r=(t=h.length)-(n=a.length))>0)for(;r--;a[n++]=0);for(r=1e14-1;t>s;){if(a[--t]<h[t]){for(n=t;n&&!a[--n];a[n]=r);--a[n],a[t]+=1e14}a[t]-=h[t]}for(;0==a[0];a.splice(0,1),--c);return a[0]?G(e,a,c):(e.s=3==x?-1:1,e.c=[e.e=0],e)},E.modulo=E.mod=function(e,r){var t,i,o=this;return e=new j(e,r),!o.c||!e.s||e.c&&!e.c[0]?new j(NaN):!e.c||o.c&&!o.c[0]?new j(o):(9==I?(i=e.s,e.s=1,t=n(o,e,0,3),e.s=i,t.s*=i):t=n(o,e,0,I),(e=o.minus(t.times(e))).c[0]||1!=I||(e.s=o.s),e)},E.multipliedBy=E.times=function(e,r){var n,t,i,o,u,s,f,c,a,h,p,g,d,w=this,v=w.c,m=(e=new j(e,r)).c;if(!(v&&m&&v[0]&&m[0]))return!w.s||!e.s||v&&!v[0]&&!m||m&&!m[0]&&!v?e.c=e.e=e.s=null:(e.s*=w.s,v&&m?(e.c=[0],e.e=0):e.c=e.e=null),e;for(t=l(w.e/14)+l(e.e/14),e.s*=w.s,(f=v.length)<(h=m.length)&&(d=v,v=m,m=d,i=f,f=h,h=i),i=f+h,d=[];i--;d.push(0));for(1e14,1e7,i=h;--i>=0;){for(n=0,p=m[i]%1e7,g=m[i]/1e7|0,o=i+(u=f);o>i;)n=((c=p*(c=v[--u]%1e7)+(s=g*c+(a=v[u]/1e7|0)*p)%1e7*1e7+d[o]+n)/1e14|0)+(s/1e7|0)+g*a,d[o--]=c%1e14;d[o]=n}return n?++t:d.splice(0,1),G(e,d,t)},E.negated=function(){var e=new j(this);return e.s=-e.s||null,e},E.plus=function(e,r){var n,t=this,i=t.s;if(r=(e=new j(e,r)).s,!i||!r)return new j(NaN);if(i!=r)return e.s=-r,t.minus(e);var o=t.e/14,u=e.e/14,s=t.c,f=e.c;if(!o||!u){if(!s||!f)return new j(i/0);if(!s[0]||!f[0])return f[0]?e:new j(s[0]?t:0*i)}if(o=l(o),u=l(u),s=s.slice(),i=o-u){for(i>0?(u=o,n=f):(i=-i,n=s),n.reverse();i--;n.push(0));n.reverse()}for((i=s.length)-(r=f.length)<0&&(n=f,f=s,s=n,r=i),i=0;r;)i=(s[--r]=s[r]+f[r]+i)/1e14|0,s[r]=1e14===s[r]?0:s[r]%1e14;return i&&(s=[i].concat(s),++u),G(e,s,u)},E.precision=E.sd=function(e,r){var n,t,i,o=this;if(null!=e&&e!==!!e)return h(e,1,1e9),null==r?r=x:h(r,0,8),F(new j(o),e,r);if(!(n=o.c))return null;if(t=14*(i=n.length-1)+1,i=n[i]){for(;i%10==0;i/=10,t--);for(i=n[0];i>=10;i/=10,t++);}return e&&o.e+1>t&&(t=o.e+1),t},E.shiftedBy=function(e){return h(e,-9007199254740991,9007199254740991),this.times("1e"+e)},E.squareRoot=E.sqrt=function(){var e,r,t,i,o,u=this,s=u.c,f=u.s,a=u.e,h=S+4,p=new j("0.5");if(1!==f||!s||!s[0])return new j(!f||f<0&&(!s||s[0])?NaN:s?u:1/0);if(0==(f=Math.sqrt(+z(u)))||f==1/0?(((r=c(s)).length+a)%2==0&&(r+="0"),f=Math.sqrt(+r),a=l((a+1)/2)-(a<0||a%2),t=new j(r=f==1/0?"1e"+a:(r=f.toExponential()).slice(0,r.indexOf("e")+1)+a)):t=new j(f+""),t.c[0])for((f=(a=t.e)+h)<3&&(f=0);;)if(o=t,t=p.times(o.plus(n(u,o,h,1))),c(o.c).slice(0,f)===(r=c(t.c)).slice(0,f)){if(t.e<a&&--f,"9999"!=(r=r.slice(f-3,f+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(F(t,t.e+S+2,1),e=!t.times(t).eq(u));break}if(!i&&(F(o,o.e+S+2,0),o.times(o).eq(u))){t=o;break}h+=4,f+=4,i=1}return F(t,t.e+S+1,x,e)},E.toExponential=function(e,r){return null!=e&&(h(e,0,1e9),e++),C(this,e,r,1)},E.toFixed=function(e,r){return null!=e&&(h(e,0,1e9),e=e+this.e+1),C(this,e,r)},E.toFormat=function(e,r,n){var t,i=this;if(null==n)null!=e&&r&&"object"==typeof r?(n=r,r=null):e&&"object"==typeof e?(n=e,e=r=null):n=L;else if("object"!=typeof n)throw Error(u+"Argument not an object: "+n);if(t=i.toFixed(e,r),i.c){var o,s=t.split("."),f=+n.groupSize,l=+n.secondaryGroupSize,c=n.groupSeparator||"",a=s[0],h=s[1],p=i.s<0,g=p?a.slice(1):a,d=g.length;if(l&&(o=f,f=l,l=o,d-=o),f>0&&d>0){for(o=d%f||f,a=g.substr(0,o);o<d;o+=f)a+=c+g.substr(o,f);l>0&&(a+=c+g.slice(o)),p&&(a="-"+a)}t=h?a+(n.decimalSeparator||"")+((l=+n.fractionGroupSize)?h.replace(new RegExp("\\d{"+l+"}\\B","g"),"$&"+(n.fractionGroupSeparator||"")):h):a}return(n.prefix||"")+t+(n.suffix||"")},E.toFraction=function(e){var r,t,i,o,s,l,a,h,p,g,d,w,v=this,m=v.c;if(null!=e&&(!(a=new j(e)).isInteger()&&(a.c||1!==a.s)||a.lt(A)))throw Error(u+"Argument "+(a.isInteger()?"out of range: ":"not an integer: ")+z(a));if(!m)return new j(v);for(r=new j(A),p=t=new j(A),i=h=new j(A),w=c(m),s=r.e=w.length-v.e-1,r.c[0]=f[(l=s%14)<0?14+l:l],e=!e||a.comparedTo(r)>0?s>0?r:p:a,l=D,D=1/0,a=new j(w),h.c[0]=0;g=n(a,r,0,1),1!=(o=t.plus(g.times(i))).comparedTo(e);)t=i,i=o,p=h.plus(g.times(o=p)),h=o,r=a.minus(g.times(o=r)),a=o;return o=n(e.minus(t),i,0,1),h=h.plus(o.times(p)),t=t.plus(o.times(i)),h.s=p.s=v.s,d=n(p,i,s*=2,x).minus(v).abs().comparedTo(n(h,t,s,x).minus(v).abs())<1?[p,i]:[h,t],D=l,d},E.toNumber=function(){return+z(this)},E.toPrecision=function(e,r){return null!=e&&h(e,1,1e9),C(this,e,r,2)},E.toString=function(e){var r,n=this,t=n.s,i=n.e;return null===i?t?(r="Infinity",t<0&&(r="-"+r)):r="NaN":(null==e?r=i<=P||i>=M?g(c(n.c),i):d(c(n.c),i,"0"):10===e?r=d(c((n=F(new j(n),S+i+1,x)).c),n.e,"0"):(h(e,2,U.length,"Base"),r=w(d(c(n.c),i,"0"),10,e,t,!0)),t<0&&n.c[0]&&(r="-"+r)),r},E.valueOf=E.toJSON=function(){return z(this)},E._isBigNumber=!0,E[Symbol.toStringTag]="BigNumber",E[Symbol.for("nodejs.util.inspect.custom")]=E.valueOf,null!=r&&j.set(r),j}();r.default=w}]);


"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

function mul(a,b){
  var ah = a >> 16, al = a & 0xffff;
  var h = ah * b, l = al * b;
  l += 0x10000 * (h & 0xffff), h = Math.floor(h / 0x10000);
  h += Math.floor(l / 0x100000000);
  return [l>>>0,h];
}
function add(a,b){
  var l = a[0]+b[0], h = a[1]+b[1];
  if(l > 0xffffffff)h++, l -= 0x100000000;
  return [l,h>>0];
}
function minus(a,b){
  var l = a[0]-b[0], h = a[1]-b[1];
  if(l < 0)h--, l += 0x100000000;
  return [l,h>>0];
}
function half(a){
  return [(a[0]>>>1) + (a[1]&1 ? 0x80000000 : 0),a[1]>>1];
}
function compare(a,b){
  if(a[1]>b[1])return 1;
  if(a[1]<b[1])return -1;
  if(a[0]>b[0])return 1;
  if(a[0]<b[0])return -1;
  return 0;
}
function toString(a){
  var neg = 0;
  if(a[1] < 0){
    neg = 1, a[1] = -a[1];
    if(a[0])a[0] = 0x100000000 - a[0], a[1]--;
  }
  var ih = 42949, il = 67296;
  var al = a[1] * il + a[0], ah = a[1] * ih + Math.floor(al / 100000);
  al %= 100000;
  var res = "";
  if(ah === 0)res += al;
  else{
    al = ("00000" + al).slice(-5);
    res = ah + al;
  }
  if(neg && res !== "0")res = "-" + res;
  return res;
}

var zero = 0, neg = [], pos = [];
var nsize, psize;

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  for(var i = 0; i < n; i++){
    var a = next();
    if(a === 0)zero++;
    else if(a < 0)neg.push(a);
    else pos.push(a);
  }
  nsize = neg.length, psize = pos.length;
  neg.sort((a,b)=>a-b);
  pos.sort((a,b)=>a-b);
  var u = nsize * psize;
  if(k <= u)return negsolve(k);
  u += (2*n - zero - 1) * zero / 2;
  if(k <= u)return 0;
  return possolve(k-u);
}

function negsolve(k){
  var ok = [0xffffffff,-1], ng = add(ok,mul(-1e9,1e9));
  while(compare(minus(ok,ng),[1,0]) === 1){
    var m = half(add(ok,ng)), cnt = 0, l = 0;
    for(var i = 0; i < psize && cnt < k; i++){
      while(l < nsize && compare(mul(neg[l],pos[i]), m) <= 0)l++;
      cnt += l;
    }
    if(k <= cnt)ok = m; else ng = m;
  }
  return toString(ok);
}

function possolve(k){
  neg.reverse();
  var ok = mul(1e9,1e9), ng = [0,0];
  while(compare(minus(ok,ng),[1,0]) === 1){
    var m = half(add(ok,ng)), cnt = 0;
    for(var i = 0, l = psize-1; i < psize && cnt < k; i++){
      while(l > i && compare(mul(pos[l],pos[i]), m) > 0)l--;
      if(l <= i)break;
      cnt += l-i;
    }
    for(var i = 0, l = nsize-1; i < nsize && cnt < k; i++){
      while(l > i && compare(mul(neg[l],neg[i]), m) > 0)l--;
      if(l <= i)break;
      cnt += l-i;
    }
    if(k <= cnt)ok = m; else ng = m;
  }
  return toString(ok);
}