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

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

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

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

a.w = g
g.t = i
n.q = g
i.w = g
k.q = g
assert a.w.t.w.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

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

a.w = g
g.t = i
n.q = g
i.w = g
k.q = g
assert a.w.t.w.t.txt == "i"