#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4 * atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const string YES = "Possible";
const string NO = "Impossible";
int N;
int M;
int s[20], c[20];
void solve() {
  if (N < M)
    cout << -1 << '\n';
  else {
    for (int i = 0; i < M; ++i)
      for (int j = i + 1; j < M; ++j) {
        if (s[i] == s[j] && c[i] != c[j]) {
          cout << -1 << '\n';
          return;
        }
      }
    string num(N, '?');
    for (int i = 0; i < M; ++i) num[s[i] - 1] = c[i] + '0';
    if (num[0] == '0') {
      if (N == 1)
        cout << 0 << '\n';
      else
        cout << -1 << '\n';
      return;
    } else {
      if (num[0] == '?') {
        if (N == 1)
          num[0] = '0';
        else
          num[0] = '1';
      }
      for (int i = 1; i < N; ++i)
        if (num[i] == '?') num[i] = '0';
      cout << num << '\n';
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (int i = 0; i < M; ++i) cin >> s[i] >> c[i];
  solve();
  return 0;
}
