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

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

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

a = A("a")
m = B("m")
g = C("g")
j = A("j")
l = B("l")

a.x = l
a.u = m
m.o = j
g.x = m
j.x = m
j.u = m
l.o = a
assert m.o.u.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.u: B = None
        self.txt = txt

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

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

a = A("a")
m = B("m")
g = C("g")
j = A("j")
l = B("l")

a.x = l
a.u = m
m.o = j
g.x = m
j.x = m
j.u = m
l.o = a
assert m.o.u.o.txt == "j"