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

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

h = A("h")
k = B("k")
d = A("d")
i = A("i")
n = A("n")
c = B("c")

h.r = k
k.u = c
d.r = k
i.r = c
n.r = c
c.u = k
assert n.r.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

h = A("h")
k = B("k")
d = A("d")
i = A("i")
n = A("n")
c = B("c")

h.r = k
k.u = c
d.r = k
i.r = c
n.r = c
c.u = k
assert n.r.u.u.u.u.txt == "c"