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

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

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

l = A("l")
j = B("j")
k = C("k")
n = B("n")

l.z = n
l.o = k
j.s = k
k.q = l
n.s = k
assert n.s.q.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.o: C = None
        self.txt = txt

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

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

l = A("l")
j = B("j")
k = C("k")
n = B("n")

l.z = n
l.o = k
j.s = k
k.q = l
n.s = k
assert n.s.q.z.s.txt == "k"