Help me in solving LBC21 problem

My issue

My code

// Update the code below to solve this problem

#include <iostream>
#include <string>
using namespace std;

int main() 
{
  int t;
  cin>>t; 
  while(t--)
  {
  int P;
  cin>>P;
  if(P>=0 && P%100<=10 && P<=1000)
  {
      cout<<(P/100 + (P%100))<<endl;
  }
  else
  {
      cout<<"-1"<<endl;
  }
  
   }
return 0;
}

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone

@yogesh_1029
The logic seems incorrect .
for 506 it will give 11 as answer which is not possible