#include <iostream>
using namespace std;
string a,getstring;
int n,s;
int main()
{
cin>>a;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>s;
if(s1)
{
cin>>getstring;
a+=getstring;
}
else if(s2)
{
cout<<a.length()<<endl;
}
else
{
cin>>getstring;
if(getstring>a)
{
cout<<getstring<<endl;
}
else cout<<a<<endl;
}
}
}