#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);
    for (int i = 0; i < M; i++) cin >> D[i].first >> D[i].second;
    sort(D.begin(), D.end());
    bool ans = true;
    for (int i = 0; i < M - 1; i++) {
      if (D[i].first == D[i + 1].first && D[i].second != D[i + 1].second) {
        ans = false;
        break;
      }
    }
    if (D[0].first == 1 && D[0].second == 0) ans = false;
    if (ans) {
      string out = "";
      int index = 0;
      vector<int> tmp(N, -1);
      for (int i = 1; i <= N; i++) {
        for (int j = 0; j < M; j++) {
          if (i == D[j].first) {
            tmp[i - 1] = D[j].second;
            break;
          }
        }
      }
      for (int i = 0; i < N; i++) {
        if (tmp[i] == -1)
          out += '0';
        else
          out += to_string(tmp[i]);
      }
      cout << out << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
signed main() { solve(); }
