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

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

k = A("k")
e = B("e")
m = C("m")
b = C("b")
l = B("l")
j = A("j")
h = B("h")
i = C("i")
d = B("d")

k.x = b
k.r = j
e.t = m
m.y = b
b.y = m
l.t = i
j.x = b
j.r = k
h.t = b
i.y = m
d.t = m
assert i.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.r: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

k = A("k")
e = B("e")
m = C("m")
b = C("b")
l = B("l")
j = A("j")
h = B("h")
i = C("i")
d = B("d")

k.x = b
k.r = j
e.t = m
m.y = b
b.y = m
l.t = i
j.x = b
j.r = k
h.t = b
i.y = m
d.t = m
assert i.y.y.y.y.txt == "b"