DMOPC '16 Contest 2 P3 - Queries

View as PDF

Submit solution

Points: 7
Time limit: 0.6s
Memory limit: 64M

Problem types
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You receive M queries with the form of (x,y). Find a sequence of size N, formed with a's and b's where you must "find" each query. A query is found if you can find a substring with x a's and y b's.

Input Specification

On the first line you will find the number of testcases, T\ (1 \le T \le 50).
For each testcase, you will find on the first line N and M (1 \le N \le 50,\ 1 \le M \le 500).
On the next M lines, you will find the queries with the space-separated integers x and y.

Output Specification

For each testcase, print a sequence which respects the requirement. If you can't find a sequence, print -1.

Sample Input

7 2
4 2
3 3

Sample Output



There are no comments at the moment.