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

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

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

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

i.o = d
f.t = k
f.z = k
f.r = i
d.p = k
d.r = j
d.q = j
k.p = d
k.r = j
k.q = f
j.t = k
j.z = d
j.r = i
assert d.r.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

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

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

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

i.o = d
f.t = k
f.z = k
f.r = i
d.p = k
d.r = j
d.q = j
k.p = d
k.r = j
k.q = f
j.t = k
j.z = d
j.r = i
assert d.r.r.o.txt == "d"