





"""simple docstring"""


from collections import deque





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Any		)->		Any:
       return input(snake_case		).strip().split(' '		)





def SCREAMING_SNAKE_CASE_   (       snake_case   :					int						,  snake_case   :					int		)->		dict[int, list[int]]:
       _lowerCamelCase    	=					{}
       for i in range(snake_case		):
              _lowerCamelCase    	=					[]

       for e in range(snake_case		):
              _lowerCamelCase	,	_lowerCamelCase    	=					(int(snake_case		) for i in _input(f'Edge {e + 1}: <node1> <node2> '		))
              graph[x].append(snake_case		)
       return graph





def SCREAMING_SNAKE_CASE_   (       snake_case   :					int						,  snake_case   :					int		)->		dict[int, list[int]]:
       _lowerCamelCase    	=					{}
       for i in range(snake_case		):
              _lowerCamelCase    	=					[]

       for e in range(snake_case		):
              _lowerCamelCase	,	_lowerCamelCase    	=					(int(snake_case		) for i in _input(f'Edge {e + 1}: <node1> <node2> '		))
              graph[x].append(snake_case		)
              graph[y].append(snake_case		)
       return graph





def SCREAMING_SNAKE_CASE_   (       snake_case   :					int						,  snake_case   :					int		)->		dict[int, list[tuple[int, int]]]:
       _lowerCamelCase    	=					{}
       for i in range(snake_case		):
              _lowerCamelCase    	=					[]

       for e in range(snake_case		):
              _lowerCamelCase	,	_lowerCamelCase	,	_lowerCamelCase    	=					(int(snake_case		) for i in _input(f'Edge {e + 1}: <node1> <node2> <weight> '		))
              graph[x].append((y, w)		)
              graph[y].append((x, w)		)
       return graph


if __name__ == "__main__":
      A_							,	A_     :      Optional[int]								=(int(i) for i in _input("""Number of nodes and edges: """))

      A_     :      str								=int(
          _input(
              """Press 1 or 2 or 3 \n"""
              """1. Unweighted directed \n"""
              """2. Unweighted undirected \n"""
              """3. Weighted undirected \n"""
          )[0]
      )

      A_     :      Optional[Any]								={
          1: initialize_unweighted_directed_graph,
          2: initialize_unweighted_undirected_graph,
          3: initialize_weighted_undirected_graph,
      }[graph_choice](n, m)





def SCREAMING_SNAKE_CASE_   (       snake_case   :					str						,  snake_case   :					Tuple		)->		Union[str, Any]:
       _lowerCamelCase	,	_lowerCamelCase    	=					{s}, [s]
       print(snake_case		)
       while _s:
              _lowerCamelCase    	=					0
              for i in g[_s[-1]]:
                     if i not in vis:
                            _s.append(snake_case		)
                            vis.add(snake_case		)
                            _lowerCamelCase    	=					1
                            print(snake_case		)
                            break
              if not flag:
                     _s.pop()





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Optional[Any]						,  snake_case   :					Any		)->		List[Any]:
       _lowerCamelCase	,	_lowerCamelCase    	=					{s}, deque([s]		)
       print(snake_case		)
       while q:
              _lowerCamelCase    	=					q.popleft()
              for v in g[u]:
                     if v not in vis:
                            vis.add(snake_case		)
                            q.append(snake_case		)
                            print(snake_case		)





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Optional[Any]						,  snake_case   :					List[Any]		)->		List[Any]:
       _lowerCamelCase	,	_lowerCamelCase	,	_lowerCamelCase    	=					{s: 0}, set(), {s: 0}
       while True:
              if len(snake_case		) == len(snake_case		) - 1:
                     break
              _lowerCamelCase    	=					100_000
              for i in dist:
                     if i not in known and dist[i] < mini:
                            _lowerCamelCase    	=					dist[i]
                            _lowerCamelCase    	=					i
              known.add(snake_case		)
              for v in g[u]:
                     if v[0] not in known and dist[u] + v[1] < dist.get(v[0]						,  100_000		):
                            _lowerCamelCase    	=					dist[u] + v[1]
                            _lowerCamelCase    	=					u
       for i in dist:
              if i != s:
                     print(dist[i]		)





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Optional[Any]						,  snake_case   :					List[Any]=None						,  snake_case   :					Tuple=None		)->		Dict:
       if q is None:
              _lowerCamelCase    	=					[1]
       if ind is None:
              _lowerCamelCase    	=					[0] * (len(snake_case		) + 1)  # SInce oth Index is ignored
              for u in g:
                     for v in g[u]:
                            ind[v] += 1
              _lowerCamelCase    	=					deque()
              for i in g:
                     if ind[i] == 0:
                            q.append(snake_case		)
       if len(snake_case		) == 0:
              return
       _lowerCamelCase    	=					q.popleft()
       print(snake_case		)
       for w in g[v]:
              ind[w] -= 1
              if ind[w] == 0:
                     q.append(snake_case		)
       topo(snake_case						,  snake_case						,  snake_case		)





def SCREAMING_SNAKE_CASE_   (       )->		Any:
       _lowerCamelCase    	=					input().strip()
       _lowerCamelCase    	=					[]
       for _ in range(snake_case		):
              a.append(map(snake_case						,  input().strip().split()		)		)
       return a, n





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Any		)->		List[Any]:
       ((_lowerCamelCase)	,	(_lowerCamelCase))    	=					a_and_n
       _lowerCamelCase    	=					list(snake_case		)
       _lowerCamelCase    	=					[[0] * n for i in range(snake_case		)]
       for k in range(snake_case		):
              for i in range(snake_case		):
                     for j in range(snake_case		):
                            if dist[i][j] > dist[i][k] + dist[k][j]:
                                   _lowerCamelCase    	=					dist[i][k] + dist[k][j]
                                   _lowerCamelCase    	=					k
       print(snake_case		)





def SCREAMING_SNAKE_CASE_   (       snake_case   :					str						,  snake_case   :					Optional[Any]		)->		List[Any]:
       _lowerCamelCase	,	_lowerCamelCase	,	_lowerCamelCase    	=					{s: 0}, set(), {s: 0}
       while True:
              if len(snake_case		) == len(snake_case		) - 1:
                     break
              _lowerCamelCase    	=					100_000
              for i in dist:
                     if i not in known and dist[i] < mini:
                            _lowerCamelCase    	=					dist[i]
                            _lowerCamelCase    	=					i
              known.add(snake_case		)
              for v in g[u]:
                     if v[0] not in known and v[1] < dist.get(v[0]						,  100_000		):
                            _lowerCamelCase    	=					v[1]
                            _lowerCamelCase    	=					u
       return dist





def SCREAMING_SNAKE_CASE_   (       )->		Optional[int]:
       _lowerCamelCase	,	_lowerCamelCase    	=					map(snake_case						,  input().split(' '		)		)
       _lowerCamelCase    	=					[]
       for _ in range(snake_case		):
              edges.append(map(snake_case						,  input().split(' '		)		)		)
       return edges, n





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Any		)->		Dict:
       # Sort edges on the basis of distance
       ((_lowerCamelCase)	,	(_lowerCamelCase))    	=					e_and_n
       e.sort(reverse=snake_case						,  key=lambda snake_case		: x[2]		)
       _lowerCamelCase    	=					[{i} for i in range(1						,  n + 1		)]
       while True:
              if len(snake_case		) == 1:
                     break
              print(snake_case		)
              _lowerCamelCase    	=					e.pop()
              for i in range(len(snake_case		)		):
                     if x[0] in s[i]:
                            break
              for j in range(len(snake_case		)		):
                     if x[1] in s[j]:
                            if i == j:
                                   break
                            s[j].update(s[i]		)
                            s.pop(snake_case		)
                            break





def SCREAMING_SNAKE_CASE_   (       snake_case   :					Union[str, Any]		)->		Any:
       _lowerCamelCase    	=					[]
       for node in graph:
              if not graph[node]:
                     isolated.append(snake_case		)
       return isolated













"""simple docstring"""


A_     :      Dict								=1_0**8





def SCREAMING_SNAKE_CASE_   (       snake_case   :					int		)->		bool:
       if n % 10 == 0:
              return False
       _lowerCamelCase    	=					str(snake_case		)
       return s == s[::-1]





def SCREAMING_SNAKE_CASE_   (       )->		int:
       _lowerCamelCase    	=					set()
       _lowerCamelCase    	=					1
       _lowerCamelCase    	=					5
       while sum_squares < LIMIT:
              _lowerCamelCase    	=					first_square + 1
              while sum_squares < LIMIT:
                     if is_palindrome(snake_case		):
                            answer.add(snake_case		)
                     last_square += 1
                     sum_squares += last_square**2
              first_square += 1
              _lowerCamelCase    	=					first_square**2 + (first_square + 1) ** 2

       return sum(snake_case		)


if __name__ == "__main__":
      print(solution())






