#include <bits/stdc++.h>
using namespace std;
void solve() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    if (N == 1) {
      cout << 0 << endl;
    } else {
      string out = "";
      for (int i = 0; i < N; i++) {
        if (i == 0)
          out += '1';
        else
          out += '0';
      }
      cout << out << endl;
    }
  } else {
    vector<pair<int, int>> D(M);
    vector<int> tmp(N, -1);
    for (int i = 0; i < M; i++) cin >> D[i].first >> D[i].second;
    sort(D.begin(), D.end());
    bool flag = true;
    for (int i = 0; i < M; i++) {
      int s = D[i].first;
      int c = D[i].second;
      if (tmp[s - 1] == -1) {
        tmp[s - 1] = c;
      } else if (tmp[s - 1] != c) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      cout << -1 << endl;
    } else {
      if (tmp[0] == 0) {
        cout << -1 << endl;
      } else {
        string out = "";
        for (int i = 0; i < N; i++) {
          if (tmp[i] == -1) {
            if (i == 0)
              out += '1';
            else
              out += '0';
          } else {
            out += to_string(tmp[i]);
          }
        }
        cout << out << endl;
      }
    }
  }
}
signed main() { solve(); }
