#include <bits/stdc++.h>
using namespace std;
int a[10];
int main() {
  int n, m;
  cin >> n >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    a[x] = y;
  }
  if (a[1] == 0)
    puts("-1");
  else {
    int num = 0;
    for (int i = 1; i <= n; i++) {
      num = num * 10 + a[i];
    }
    if (num > 0)
      cout << num << endl;
    else
      puts("-1");
  }
  return 0;
}
