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

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: A = None
        self.z: A = None
        self.txt = txt

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

l.u = m
m.o = a
m.q = a
m.u = l
a.p = m
a.s = l
a.z = l
assert l.u.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: B = None
        self.s: A = None
        self.z: A = None
        self.txt = txt

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

l.u = m
m.o = a
m.q = a
m.u = l
a.p = m
a.s = l
a.z = l
assert l.u.q.p.txt == "m"