#include <bits/stdc++.h>
using namespace std;
string itos(int x) {
  string ans;
  while (x) {
    ans.push_back(x % 10 + '0');
    x /= 10;
  }
  return ans;
}
const int MAXN = 10;
int a[MAXN], b[MAXN];
int main(void) {
  int N, M;
  cin >> N >> M;
  for (int(i) = 0; i < (int)(M); i++) cin >> a[i] >> b[i];
  for (int(i) = 0; i < (int)(1000); i++) {
    string s = itos(i);
    bool va = true;
    if (s.size() == N) {
      for (int(j) = 0; j < (int)(M); j++)
        if (s[a[j] - 1] != (char)b[j] + '0') va = false;
      if (va) {
        cout << s << endl;
        return 0;
      }
    }
  }
  cout << -1 << endl;
  return 0;
}
