#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e5 + 3;
const long long N = 1e2 + 200;
const long long INF = 9999999999999;
const double eps = 1e-7;
int main() {
  long long n, m;
  cin >> n >> m;
  int x, y;
  int flag = 0;
  long long sum = 0;
  int mp[20];
  string s = "000000";
  memset(mp, -1, sizeof(mp));
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    if (mp[x] != -1 && mp[x] != y) {
      flag = 1;
    } else {
      mp[x] = y;
    }
    s[x] = y + '0';
  }
  if (n == 1 && s == "000000") {
  } else
    for (int i = 1; i <= n; i++) {
      if (s[i] == '0') {
        flag = 1;
      } else {
        break;
      }
    }
  if (flag) {
    cout << "-1" << endl;
  } else {
    for (int i = 1; i <= n; i++) {
      cout << s[i];
    }
    cout << endl;
  }
  return 0;
}
