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

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

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

n = A("n")
g = B("g")
k = C("k")
c = A("c")
h = C("h")

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

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

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

n = A("n")
g = B("g")
k = C("k")
c = A("c")
h = C("h")

n.t = g
n.w = g
n.y = h
g.u = k
g.w = c
k.z = c
c.t = g
c.w = g
c.y = k
h.z = n
assert k.z.y.z.t.u.txt == "k"