#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> S(M), C(M);
  for (int i = 0; i < M; i++) cin >> S[i] >> C[i];
  string s;
  for (int i = 0; i < N; i++) s.push_back('#');
  for (int i = 0; i < M; i++) {
    if (s[S[i] - 1] == '#')
      s[S[i] - 1] = C[i] + '0';
    else if (s[S[i] - 1] == '0' + C[i])
      continue;
    else {
      puts("-1");
      return 0;
    }
  }
  if (s[0] == '0' and N >= 2) {
    puts("-1");
    return 0;
  }
  if (s[0] == '#') s[0] = '1';
  for (int i = 1; i < N; i++) {
    if (s[i] == '#') s[i] = '0';
  }
  cout << s << endl;
}
