#include <bits/stdc++.h>
#pragma GCC optimize("O3")
constexpr auto INF = 9223372036854775807;
using namespace std;
long long int inverse(long long int n) {
  long long int modu = 998244353;
  long long int m = modu;
  long long int a = 0, b = 1;
  if (modu == 1) return 0;
  while (n > 1) {
    long long int quo = n / modu;
    long long int temp = modu;
    modu = n % modu, n = temp;
    temp = a;
    a = b - (quo * a);
    b = temp;
  }
  if (b < 0) b += m;
  return b;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long int n, k;
  cin >> n >> k;
  string ans = "";
  for (long long int i = (long long int)0; i < (long long int)n; i += 1)
    ans += "a";
  for (long long int i = (long long int)0; i < (long long int)k; i += 1) {
    long long int s;
    char c;
    cin >> s >> c;
    if (ans != "-1") {
      if (ans[s - 1] != 'a' && ans[s - 1] != c)
        ans = "-1";
      else {
        ans[s - 1] = c;
      }
    }
  }
  if (ans[0] == 'a') ans[0] = '1';
  for (long long int i = (long long int)0; i < (long long int)n; i += 1) {
    if (ans[i] == 'a') ans[i] = '0';
  }
  cout << ans;
  return 0;
}
