G-8 nations vow to cooperate on terrorism