Returning trajectory from beam search