#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int N, M;
vector<int> s, c;
int main() {
  cin >> N >> M;
  s.resize(M);
  c.resize(M);
  for (int i = 0; i < (M); ++i) {
    cin >> s[i] >> c[i];
  }
  map<int, int> mp;
  for (int i = 0; i < (M); ++i) {
    s[i]--;
    if (mp.count(s[i]) && mp[s[i]] != c[i]) {
      cout << -1 << endl;
      return 0;
    }
    mp[s[i]] = c[i];
  }
  vector<int> ans(N);
  for (int i = 0; i < (N); ++i) {
    ans[i] = -1;
  }
  for (int i = 0; i < (M); ++i) {
    ans[s[i]] = c[i];
  }
  if (ans[0] == 0 && N != 1) {
    cout << -1 << endl;
    return 0;
  }
  if (N != 1) {
    if (ans[0] == -1) {
      ans[0] = 1;
    } else if (ans[1] == -1) {
      ans[1] = 0;
    } else if (ans[2] == -1) {
      ans[2] = 0;
    }
  } else {
    ans[0] = 0;
  }
  for (int i = 0; i < (N); ++i) {
    cout << ans[i];
  }
  cout << endl;
}
