#include <bits/stdc++.h>
using namespace std;
long long N = 500005;
long long MAX = 9223372036854775807;
long long MOD = 1000000007;
long double PI = 4 * atan(1);
long long n, m, k;
long long nbr;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  std::cout << std::setprecision(30);
  long long n, k;
  cin >> n >> k;
  vector<long long> dp(n, 0);
  string ch = "";
  for (int i = 0; i < n; i++) {
    ch += '0';
  }
  ch[0] = '1';
  for (int i = 0; i < k; i++) {
    long long x, y;
    cin >> x >> y;
    if (dp[x - 1] == 0 || dp[x - 1] == y) {
      dp[x - 1] = y;
      ch[x - 1] = (y + '0');
    } else
      return cout << -1, 0;
  }
  if (ch[0] == '0')
    cout << -1;
  else
    cout << ch;
  return 0;
}
