#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long GCD(long long a, long long b) { return b ? GCD(b, a % b) : a; }
int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int> > sc(M);
  int Max = 0;
  for (int i = 0; i < M; i++) {
    cin >> sc[i].first >> sc[i].second;
    sc[i].first--;
    Max = max(sc[i].first, Max);
  }
  for (int i = 1; i < 1000; i++) {
    string x;
    x = to_string(i);
    if (x.size() != N) continue;
    bool ok = true;
    for (int j = 0; j < M; j++) {
      if (x[sc[j].first] != '0' + sc[j].second) ok = false;
    }
    if (ok) {
      cout << x << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}
