#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;
ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
const ll INF = 1LL << 50;
int main() {
  ll n, m;
  cin >> n >> m;
  string str = "";
  for (ll i = 0; i < (n); ++i) str += "?";
  for (ll i = 0; i < (m); ++i) {
    ll s;
    char c;
    cin >> s >> c;
    s--;
    bool cond = (str[s] == '?') || (str[s] == c);
    if (cond) {
      str[s] = c;
    } else {
      puts("-1");
      return 0;
    }
  }
  if (str[0] == '0') {
    puts("-1");
    return 0;
  }
  if (str[0] == '?') {
    if (n == 1)
      str[0] = '0';
    else
      str[0] = '1';
  }
  for (ll i = 1; i < n; i++) {
    if (str[i] == '?') str[i] = '0';
  }
  cout << str << endl;
  return 0;
}
