#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)
#define rep(i,n) for(ll i=0;i<n;i++)
int main(){
vector<pair<ll,string>> v;
ll N;
cin>>N;
rep(i,N){
    string s;ll jjj;
    cin>>s>>jjj;
    v.push_back(mkpr(jjj,s));
}

sort(ALL(v));
reverse(ALL(v));
cout<<v[1].second<<endl;



}


#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

#include <sys/time.h>

using namespace std;


class XorShift128 {
private:
	uint32_t x, y, z, w;

public:
	XorShift128() : x(123456789), y(362436069), z(521288629), w(88675123) { }
	uint32_t rnd() {
		uint32_t t = x ^ (x << 11);
		x = y;
		y = z;
		z = w;
		return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
	}

	uint32_t rnd(const int n) {
		return rnd() % n;
	}

	uint32_t rnd(const int l, const int r) { // [l, r]
		return rnd() % (r - l + 1) + l;
	}
};

long long get_time() {
	struct timeval tv;
	gettimeofday(&tv, NULL);
	long long result =  tv.tv_sec * 1000LL + tv.tv_usec / 1000LL;
	return result;
}

XorShift128 xor_shift_128;
long long start;


class Solver {
	int N, M;
	vector<string> strs;

public:
	Solver();
	void run();

private:

};

Solver::Solver() {
	cin >> N >> M;
	strs.resize(M);
	for(int i = 0; i < M; ++i) {
		cin >> strs[i];
	}
}

void Solver::run() {
	int i = 0;
	for(int hi = 0; hi < N; ++hi) {
		int l = 0;
		while(i < M && strs[i].size() + l <= N) {
			cout << strs[i];
			l += strs[i].size();
			++i;
		}

		for(int j = 0; j < N - l; ++j) {
			cout << '.';
		}

		cout << endl;
	}
}

int main() {
	start = get_time();

	Solver solver;
	solver.run();
}