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

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

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

k = A("k")
n = B("n")
a = C("a")
f = B("f")
g = C("g")

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

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

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

k = A("k")
n = B("n")
a = C("a")
f = B("f")
g = C("g")

k.r = a
n.t = a
n.w = g
n.s = g
a.z = g
a.r = g
f.t = a
f.w = a
f.s = a
g.z = a
g.r = a
assert a.r.z.r.z.txt == "a"