How do i style the current menu anchor link’s parent anchor link? [closed]

As i got the solution so i am posting it here. WordPress uses current-menu-ancestor and current_page_ancestor classes. So we can use them as below

.mainmenu .current_page_item > a,
.mainmenu .current_page_ancestor > a,
.mainmenu .current-menu-item > a,
.mainmenu .current-menu-ancestor > a {
  font-style: italic;
}