#include <bits/stdc++.h>
using namespace std;
const long double PI = 3.1415926535897923846;
const int MOD = 1e9 + 7;
const int N = 998244353;
void solve() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp1;
  vector<bool> check(n);
  for (int i = 0; i < m; i++) {
    int place, dig;
    cin >> place >> dig;
    if (mp1.find(place) == mp1.end()) {
      mp1[place] = dig;
      check[(int)place - 1] = true;
    } else {
      if (mp1[place] != dig) {
        cout << "-1";
        return;
      }
    }
    if (n != 1 && place == 1 && dig == 0) {
      cout << "-1";
      return;
    }
  }
  if (n == 1) {
    cout << mp1[1];
    return;
  }
  for (int i = 1; i <= n; i++) {
    if (check[(int)i - 1])
      cout << mp1[i];
    else
      cout << 1;
  }
}
int main() {
  int test = 1;
  while (test--) solve();
}
