#include <bits/stdc++.h>
using namespace std;
int n, m, s;
char c;
pair<int, char> cond[5];
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> s >> c;
    cond[i] = make_pair(s, c);
  }
  for (int i = 1; i < 1000; i++) {
    string number = to_string(i);
    if (number.size() == n) {
      bool flag = false;
      for (int k = 0; k < m; k++) {
        if (number[cond[k].first - 1] != cond[k].second) {
          flag = true;
        }
      }
      if (flag) {
        continue;
      }
      cout << number;
      return 0;
    }
  }
  cout << -1;
}
