#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int MAX = 510000;
const int INF = 1e9;
const double pi = acos(-1);
int main() {
  string s = "";
  int n, m;
  cin >> n >> m;
  bool can = true;
  for (long long i = 0; i < (n); i++) s += 'a';
  for (long long i = 0; i < (m); i++) {
    char b, c;
    cin >> b >> c;
    if (s[b - '1'] == 'a')
      s[b - '1'] = c;
    else {
      if (s[b - '1'] != c) {
        can = false;
        break;
      }
    }
  }
  if (!can) {
    cout << -1 << endl;
    return 0;
  } else {
    if (s[0] == '0' && n > 1) {
      cout << -1 << endl;
      return 0;
    }
    for (long long i = 0; i < (n); i++) {
      if (s[i] == 'a') {
        if (i != 0)
          s[i] = '0';
        else
          s[i] = '1';
      }
    }
    cout << s << endl;
  }
  return 0;
}
