How to find first intersection of 2 A.P. series if exist and the term should be greater then 0

We have 2 general term of A.P. as
Tn = a + (n - 1) * b
Fm = b + (m - 1) * d

Solving Tn = Fm
nb - md = b - d - a + b
which then i interpreted as Ax - By = C
ans solved using linear diophantine equation, but i am not getting the first intersection point
for eg. let a = 52 , b = 39, c = 78, d = 88
using above method i am getting solution as 207 92 which is not even a solution to given equation.
I am directly using the implementation of cp-algorithm.

refer hackerearth’s number theory thats correct

Algorithm is not Wrong , as i have taken from cp-algorithm, i posted so that we may need to do some manipulation after or before applying Linear diophantine equation.