#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;
int n;
int m;
int s[N];
int c[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> s[i] >> c[i];
  }
  for (int i = 1; i <= 1000; i++) {
    string x = to_string(i);
    if ((int)x.size() == n) {
      int good = 1;
      for (int j = 1; j <= m; j++) {
        if (x[s[j] - 1] != (c[j] + '0')) {
          good = 0;
        }
      }
      if (good == 1) {
        cout << x << "\n";
        return 0;
      }
    }
  }
  cout << "-1\n";
}
