#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(NULL), cout.tie(0);
  int a, b, ct = 0, g = 0;
  cin >> a >> b;
  map<int, int> m;
  int flag = 0;
  for (int i = 0; i < b; i++) {
    int x, y;
    cin >> x >> y;
    m[x] = y;
    if (x == 1) g = 1;
    if (x == 1 and y == 0 and a > 1) {
      flag = 1;
    }
    if (y != 0) ct++;
  }
  if (!g) {
    cout << -1;
    return 0;
  }
  if (flag) {
    cout << -1;
    return 0;
  }
  if (ct == 0 and a > 1) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < a; i++) {
    if (!m.count(i + 1) and i != 0) {
      cout << 0;
    } else if (!m.count(i + 1) and i == 0)
      cout << 1;
    else
      cout << m[i + 1];
  }
  return 0;
}
