#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
bool isLowerCase(char c) { return (c >= 'a' && c <= 'z'); }
const string btos(bool ans) { return (ans ? "Yes" : "No"); }
int main() {
  int n, m;
  cin >> n >> m;
  string s(n, '0');
  s[0] = '1';
  map<int, char> cond;
  for (int i = 0; i < (int)(m); i++) {
    int si;
    cin >> si;
    char ci;
    cin >> ci;
    if (cond.find(si) != cond.end() && cond[si] != ci) {
      s = "-1";
      break;
    } else if (si == 1 && ci == '0') {
      s = "-1";
      break;
    }
    cond[si] = ci;
    s[si - 1] = ci;
  }
  cout << s << endl;
  return 0;
}
