#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 2e5 + 10;
const int INF = 0x3f3f3f3f;
char s[15];
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);
  std::cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= m; ++i) {
    int x;
    char c;
    cin >> x >> c;
    if (!s[x])
      s[x] = c;
    else {
      if (s[x] != c) {
        puts("-1");
        return 0;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (!s[i]) {
      if (i == 1)
        s[i] = '1';
      else
        s[i] = '0';
    }
  }
  cout << (s + 1);
  return 0;
}
