#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, M;
    cin >> N >> M;
    string num;
    for (int i = 0; i < N; i++)
    {
        num.push_back('a');
    }

    int s;
    char c;
    for (int i = 0; i < M; i++)
    {
        cin >> s >> c;
        if (num[s - 1] == 'a')
        {
            num[s - 1] = c;
        }else
        {
            if (c != num[s - 1])
            {
                cout << -1 << endl;
                return 0;
            }
            
        }
        
    }

    if (num.size > 1)
    {
        if (num[0] == 'a') num[0] = '1';
        if (num[0] == '0')
        {
            cout << -1 << endl;
            return 0;
        }
        
    }

    for (int i = 1; i < num.size(); i++)
    {
        if (num[i] == 'a') num[i] = '0';
    }
    
    int ans = stoi(num);
    cout << ans << endl;
    
    return 0;
}