public class ExactTreeEasy {
public int[] getTree(int n, int m)
{
int[] ret = new int[(n-1)*2];
int p = 0;
ret[p++] = 0; ret[p++] = 1;
ret[p++] = 1; ret[p++] = 2;
int nodeIndex = 2;
for(int i = 1; i <= m-2; i++)
{
ret[p++] = 1; ret[p++] = ++nodeIndex;
}
while(nodeIndex < n-1)
{
ret[p++] = nodeIndex; ret[p++] = ++nodeIndex;
}
return ret;
}
}
cHVibGljIGNsYXNzIEV4YWN0VHJlZUVhc3kgewogICAgcHVibGljIGludFtdIGdldFRyZWUoaW50IG4sIGludCBtKQogICAgewogICAgICAgIGludFtdIHJldCA9IG5ldyBpbnRbKG4tMSkqMl07CiAgICAgICAgaW50IHAgPSAwOwogICAgICAgIHJldFtwKytdID0gMDsgcmV0W3ArK10gPSAxOwogICAgICAgIHJldFtwKytdID0gMTsgcmV0W3ArK10gPSAyOwogICAgICAgIGludCBub2RlSW5kZXggPSAyOwogICAgICAgIGZvcihpbnQgaSA9IDE7IGkgPD0gbS0yOyBpKyspCiAgICAgICAgewogICAgICAgICAgICByZXRbcCsrXSA9IDE7IHJldFtwKytdID0gKytub2RlSW5kZXg7CiAgICAgICAgfQogICAgICAgIHdoaWxlKG5vZGVJbmRleCA8IG4tMSkKICAgICAgICB7CiAgICAgICAgICAgIHJldFtwKytdID0gbm9kZUluZGV4OyByZXRbcCsrXSA9ICsrbm9kZUluZGV4OwogICAgICAgIH0KICAgICAgICByZXR1cm4gcmV0OwogICAgfQp9Cg==