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

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

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

j = A("j")
e = B("e")
k = C("k")

j.p = e
j.q = k
j.u = k
e.p = k
k.s = e
k.q = j
assert j.u.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.q: C = None
        self.u: C = None
        self.txt = txt

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

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

j = A("j")
e = B("e")
k = C("k")

j.p = e
j.q = k
j.u = k
e.p = k
k.s = e
k.q = j
assert j.u.s.p.txt == "k"