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

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

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

i = A("i")
a = B("a")
b = C("b")
g = A("g")
f = C("f")
n = A("n")
j = A("j")

i.r = b
a.s = i
b.x = a
b.z = f
b.t = f
g.r = b
f.x = a
f.z = b
f.t = b
n.r = b
j.r = b
assert j.r.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

i = A("i")
a = B("a")
b = C("b")
g = A("g")
f = C("f")
n = A("n")
j = A("j")

i.r = b
a.s = i
b.x = a
b.z = f
b.t = f
g.r = b
f.x = a
f.z = b
f.t = b
n.r = b
j.r = b
assert j.r.t.t.txt == "b"