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

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

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

m = A("m")
e = B("e")
b = C("b")
j = A("j")
n = C("n")
g = B("g")
k = B("k")

m.w = j
e.w = g
e.z = g
b.x = k
b.s = n
j.w = m
n.x = k
n.s = b
g.w = e
g.z = k
k.w = g
k.z = e
assert e.w.z.w.z.w.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

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

m = A("m")
e = B("e")
b = C("b")
j = A("j")
n = C("n")
g = B("g")
k = B("k")

m.w = j
e.w = g
e.z = g
b.x = k
b.s = n
j.w = m
n.x = k
n.s = b
g.w = e
g.z = k
k.w = g
k.z = e
assert e.w.z.w.z.w.z.w.txt == "g"