runtime error found in input taking (as i debugged)

while(t–)
{
string s,s2;
cin>>n>>m;
z=n*m;
while(n–)
{
cin>>s2;
cout<<n<<" ";
s.append(s2);
}






}

My doubt is that why is runtime error coming for 18 and 24 but not for 3*3.Actually the string is not taking input properly.Am i not aware of any string property?

//