Ciel and A-B problem (why my solution is wrong?)

#include
using namespace std;
int main()
{
int A,B,p,q,dif;
cin>>A >>B;
dif=A-B;
p=dif/10;
if((dif%10)==9)
q=(dif%10)-1;
else
q=(dif%10)+1;
cout<<"\n"<<p<<q;
return 0;
}