/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
(new Ideone()).solve();
}
private void solve() {
int arr[] = new int[]{2,2,2};
int n = arr.length;
Pair pairs[] = new Pair[n];
for(int i = 0; i < n; i++) {
pairs[i] = new Pair(i, arr[i]);
}
TreeSet<Pair> set = new TreeSet<>((p1, p2) -> {
if(p1.val == p2.val) return p1.idx-p2.idx;
return p1.val-p2.val;
});
// HashSet<Pair> set = new HashSet<>();
for(int i = 0; i < arr.length; i++)
set.add(pairs[i]);
}
class Pair {
int idx, val;
Pair(int idx, int val) {
this.idx = idx;
this.val = val;
}
public int hashCode() {
return idx;
}
public boolean equals
(Object ob
) { return(this.idx == ((Pair)ob).idx);
}
return("{ "+idx+", "+val+" }");
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCShuZXcgSWRlb25lKCkpLnNvbHZlKCk7CgkJCgl9CgkKCXByaXZhdGUgdm9pZCBzb2x2ZSgpIHsKCQlpbnQgYXJyW10gPSBuZXcgaW50W117MiwyLDJ9OwoJCWludCBuID0gYXJyLmxlbmd0aDsKCQlQYWlyIHBhaXJzW10gPSBuZXcgUGFpcltuXTsKCQlmb3IoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CgkJCXBhaXJzW2ldID0gbmV3IFBhaXIoaSwgYX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