#include <bits/stdc++.h>
using namespace std;
int a[3][3];
void check(int c) {}
void solve() {
  int n, m;
  int s[10], c[10];
  int num[5] = {-1, -1, -1, -1, -1};
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 1; i <= m; i++) {
    if (s[i] == 1 && c[i] == 0 && n != 1) {
      cout << "-1" << endl;
      return;
    }
    if (num[s[i]] == -1)
      num[s[i]] = c[i];
    else {
      if (num[s[i]] != c[i]) {
        cout << "-1" << endl;
        return;
      }
    }
  }
  if (num[1] == -1) {
    num[1] = 1;
  }
  for (int i = 1; i <= n; i++) {
    if (i != 1 && num[i] == -1) num[i] = 0;
    cout << num[i];
  }
  cout << endl;
  return;
}
int main() { solve(); }
