#include <bits/stdc++.h>
using namespace std;
set<char> x[10];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s;
  for (int i = 0; i < n; i++) s += '0';
  for (int i = 0; i < m; i++) {
    int a;
    char c;
    cin >> a >> c;
    a--;
    s[a] = c;
    x[a].insert(c);
    if ((a == 0 && c == '0') || x[a].size() > 1) {
      cout << -1;
      return 0;
    }
  }
  if (s[0] == '0') s[0] == '1';
  cout << s;
}
