UN says thousands flee fighting in two states