class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

k = A("k")
n = B("n")
l = A("l")
h = B("h")
c = B("c")
i = A("i")
m = B("m")

k.u = i
n.v = m
l.u = k
h.v = n
c.v = m
i.u = l
m.v = c
assert l.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

k = A("k")
n = B("n")
l = A("l")
h = B("h")
c = B("c")
i = A("i")
m = B("m")

k.u = i
n.v = m
l.u = k
h.v = n
c.v = m
i.u = l
m.v = c
assert l.u.u.u.u.u.txt == "i"