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

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

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

g = A("g")
k = B("k")
b = C("b")
n = A("n")

g.w = b
g.t = n
g.z = k
k.u = n
b.u = n
n.w = b
n.t = g
n.z = k
assert g.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.t: A = None
        self.z: B = None
        self.txt = txt

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

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

g = A("g")
k = B("k")
b = C("b")
n = A("n")

g.w = b
g.t = n
g.z = k
k.u = n
b.u = n
n.w = b
n.t = g
n.z = k
assert g.z.u.z.txt == "k"