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

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

h = A("h")
k = B("k")
d = B("d")
i = A("i")
b = A("b")
g = A("g")
j = A("j")
l = A("l")

h.r = l
k.u = j
k.t = l
d.u = g
d.t = b
i.r = h
b.r = g
g.r = b
j.r = l
l.r = j
assert k.t.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

h = A("h")
k = B("k")
d = B("d")
i = A("i")
b = A("b")
g = A("g")
j = A("j")
l = A("l")

h.r = l
k.u = j
k.t = l
d.u = g
d.t = b
i.r = h
b.r = g
g.r = b
j.r = l
l.r = j
assert k.t.r.r.r.r.r.r.txt == "l"