#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <math.h>
#include <queue>
#include <set>
#pragma GCC optimize ("Ofast","unroll-loops")
#pragma GCC target ("sse")
using namespace std;
#define int long long
const int maxn=4e6+5;
int z[maxn];
void build_z(const string s) {
int n = s.size();
int best = 0;
for (int i = 1; i < n; i++) {
int R = best + z[best] - 1;
if (i <= R) {
int k = i - best;
z[i] = min(z[k], R - i + 1);
}
while (i + z[i] < n && s[z[i]] == s[i + z[i]])z[i]++;
if (i + z[i] - 1 > R)best = i;
}
}
void solve(){
string a;
string b;
cin>>a>>b;
string s='#'+a+'#'+b;
build_z(s);
for (int i=0;i<s.size();i++) {
cout<<z[i]<<" "<<s[i]<<endl;
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
t=1;
while(t--)solve();
return 0;
}