Given a singly linked list and a number **K**, your are required to complete the function **modularNode(), **that return the modular node of the linked list.

A modular node is the last node of the linked list whose Index is divisible by the number **K**, i.e. **i%k==0**.

```
Input : list = 1->2->3->4->5->6->7
k = 3
Output : 6
Input : list = 3->7->1->9->8
k = 2
Output : 9
```

**Input:**

The function takes two arguments as input, the reference pointer to the **head **of the linked list and an integer **K**.

There will be **T**, test cases and for each test the function will be called separately.

**Output:**

For each test case the function must return the modular Node data, if no such node is possible then return **"-1"**.

**Constraints:**

1<=T<=100

1<=N<=500

**Example:
Input:**

2

7

1 2 3 4 5 6 7

3

5

19 28 37 46 55

2

6

46

**Note:**The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

bhatabhi554 | 317 |

hardikJain5 | 306 |

CodeBuddy | 293 |

Akkki111 | 233 |

clone | 230 |

KshatriyaYash | 1932 |

nikhil_sojan | 1374 |

lonecoder | 1236 |

mazumderrohit8 | 1176 |

RemoveTLE | 1144 |

blackshadows | 5327 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4605 |

Quandray | 4444 |

Login to report an issue on this page.