Baghdad, KRG, UN ink deal to avoid Mosul displacement