#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[10];
char c[10];
char s[10];
int main() {
  for (int i = 1; i <= 10; i++) s[i] = '0';
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> c[i];
    if (a[i] == 1 && c[i] == '0') {
      cout << -1 << endl;
      return 0;
    }
    for (int j = 1; j < i; j++) {
      if (a[j] == a[i] && c[i] != c[j]) {
        cout << -1 << endl;
        return 0;
      }
    }
    s[a[i]] = c[i];
  }
  if (s[1] == '0') s[1] = '1';
  for (int i = 1; i <= n; i++) {
    cout << s[i];
  }
  puts("");
  return 0;
}
