#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  bool isng = false;
  vector<int> num(N, -1);
  for (int i = 0; i < M; ++i) {
    int s, c;
    cin >> s >> c;
    s--;
    if (num[s] != -1 && num[s] != c) isng = true;
    num[s] = c;
  }
  if (isng || num[0] == 0) {
    cout << -1 << endl;
    return 0;
  }
  if (num[0] == -1) num[0] = 1;
  for (int i = 0; i < N; ++i) cout << max(num[i], 0);
  cout << endl;
  return 0;
}
