Help me in solving PEPPERON problem

My issue

not getting the logic how to solve this question

My code

#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	long long t;
	cin>>t;
	while(t--){
	    long long n;
	    cin>>n;
	    vector<string>arr(n);
	    for(int i=0;i<n;i++){
	        cin>>arr[i];
	    }
	    
	}

}

Learning course: 1800 to 2000 difficulty problems
Problem Link: Chef and Pepperoni Pizza Practice Problem in 1800 to 2000 difficulty problems