The Prophet (peace and blessings of Allaah be upon him) taught his companions: when you enter the graveyard, say: “Peace be upon you, dwellers of these abodes, believers and Muslims. We will, whenever Allaah wills, join you. May Allaah have mercy on those of you who were first (to die) and those who were last. I beg of Allaah salvation for us and for you. O Allaah, deprive us not of reward (similar to theirs) and lead us not astray after they are gone, and forgive us and them.” (Saheeh Muslim, no. 974, 975)
And Allah knows best.