#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __f(const char* variable_name, T&& value) {
  cout << variable_name << ": " << value << endl;
}
template <typename T1, typename... T2>
void __f(const char* names, T1&& arg1, T2&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
const long long N = 5e5 + 5;
long long* v;
long long n, m;
void solve() {
  cin >> n >> m;
  string s;
  if (n == 1)
    s = "_";
  else if (n == 2)
    s = "_";
  else
    s = "___";
  bool poss = true;
  while (m--) {
    long long si, xi;
    cin >> si >> xi;
    if (s[si - 1] == '_')
      s[si - 1] = xi + '0';
    else if (s[si - 1] != xi + '0') {
      poss = false;
    } else {
      continue;
    }
  }
  if (poss) {
    if (s[0] == '0') {
      cout << -1 << endl;
    } else {
      if (s[0] == '_') s[0] = '1';
      for (auto& i : s)
        if (i == '_') i = '0';
      cout << s << endl;
    }
  } else
    cout << -1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
