Deal reached on Northern Ireland devolution