GCD Strings Hackerearth problem

how do i solve this problem??