@JadenPan I "stolen" those primes from some of the fastest solutions of "Number of Distinct Islands" which can be seen when you got your solution accepted.
However, they needn't to be primes, but we have to differentiate different aspects of the "Shape" of an island. A better choice may be by observing the row-by-row(column-by-column) fluctuates of heights(width) and finding out the characteristics.
@zhty9095 After sorting , you can choose any one to be the base point(left top, left bottom, etc). Also, you can choose any sorting method(Here I use the default comparision in pair<int, int>). As long as you make sure every distinct island has different string.