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

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

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

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

k.q = d
d.p = j
d.o = k
j.t = k
assert j.t.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

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

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

k.q = d
d.p = j
d.o = k
j.t = k
assert j.t.q.o.txt == "k"