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

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

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

l = A("l")
b = B("b")
d = C("d")
a = B("a")
j = A("j")
m = C("m")

l.r = j
l.y = d
b.y = m
b.t = a
d.o = m
d.u = j
a.y = d
a.t = b
j.r = l
j.y = m
m.o = d
m.u = j
assert a.t.t.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.y: C = None
        self.txt = txt

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

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

l = A("l")
b = B("b")
d = C("d")
a = B("a")
j = A("j")
m = C("m")

l.r = j
l.y = d
b.y = m
b.t = a
d.o = m
d.u = j
a.y = d
a.t = b
j.r = l
j.y = m
m.o = d
m.u = j
assert a.t.t.y.o.txt == "m"