#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<char> chr(n, '0');
  chr.at(0) = '1';
  vector<int> s(m);
  vector<char> c(m);
  for (int i = 0; i < m; i++) {
    cin >> s.at(i) >> c.at(i);
  }
  for (int i = 0; i < m; i++) {
    if (n >= 2 && s.at(i) == 1 && c.at(i) == '0') {
      cout << "-1" << endl;
      exit(0);
    }
    for (int j = i + 1; j < m; j++) {
      if ((s.at(i) == s.at(j) && c.at(i) != c.at(j))) {
        cout << "-1" << endl;
        exit(0);
      }
    }
  }
  for (int i = 0; i < m; i++) chr.at(s.at(i) - 1) = c.at(i);
  for (int i = 0; i < n; i++) {
    cout << chr.at(i);
    if (i == n - 1) cout << endl;
  }
}
