#include <bits/stdc++.h>
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...);
}
int main() {
  {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cout.tie(nullptr);
  }
  int n, m;
  cin >> n >> m;
  int a[m], b[m];
  int fl3 = 1, fl2 = 0;
  for (int i = 0; i < (int)(m); ++i) {
    cin >> a[i] >> b[i];
    if (a[i] == 1 && b[i] == 0 && n >= 2) {
      fl2 = 1;
    }
    if (a[i] == 1 && b[i] == 0 && n < 2) {
      cout << "0";
      return 0;
    }
  }
  if (fl2 == 1) {
    cout << -1;
    return 0;
  }
  for (int i = 0; i < (int)(m); ++i) {
    for (int j = 0; j < (int)(m); ++j) {
      if (a[j] == a[i]) {
        if (b[i] != b[j]) {
          cout << "-1";
          return 0;
        }
      }
    }
  }
  string str;
  int vis[n + 1];
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < (int)(n); ++i) {
    int fl = 0;
    for (int j = 0; j < (int)(m); ++j) {
      if (i + 1 == a[j] && vis[a[j]] == 0) {
        str += (b[j] + '0');
        vis[a[j]] = 1;
        fl = 1;
        break;
      }
    }
    if (i + 1 == 1 && !fl)
      str += '1';
    else if (!fl)
      str += '0';
  }
  cout << str;
  return 0;
}
