#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
using namespace std;
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template <typename T, typename V>
void __print(const pair<T, V> &x) {
  cerr << '{';
  __print(x.first);
  cerr << ',';
  __print(x.second);
  cerr << '}';
}
template <typename T>
void __print(const T &x) {
  int f = 0;
  cerr << '{';
  for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
  cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
  __print(t);
  if (sizeof...(v)) cerr << ", ";
  _print(v...);
}
const long long int MOD = 1e9 + 7;
const long long int SMOD = 998244353;
const long long int INF = 1e18;
const long long int SINF = 1e9;
const long long int MAX = 100100;
void pre() {}
void solve() {
  long long int n, m;
  cin >> n >> m;
  string s;
  for (long long int i = 0; i < (n); ++i) {
    s += "$";
  }
  {};
  for (long long int ii = 0; ii < (m); ++ii) {
    long long int p, c;
    cin >> p >> c;
    p--;
    if ((s[p] != '$') && (s[p] != char('0' + c))) {
      cout << "-1" << '\n';
      return;
    }
    s[p] = char('0' + c);
  }
  if (s[0] == '$') s[0] = '1';
  for (long long int i = 1; i < (n); ++i) {
    if (s[i] == '$') s[i] = '0';
  }
  long long int x = 0;
  {};
  for (long long int i = 0; i < (n); ++i) {
    if (s[i] != '0')
      break;
    else {
      x++;
    }
  }
  if (x && n > 1)
    cout << "-1" << '\n';
  else
    cout << s << '\n';
}
signed main() {
  clock_t begin = clock();
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int test = 1;
  for (long long int ii = 0; ii < (test); ++ii) {
    solve();
  }
  clock_t end = clock();
  double elapsed_secs = (double)(end - begin) / CLOCKS_PER_SEC;
  {};
  return 0;
}
