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

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

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

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

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

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

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

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

g.z = k
g.v = m
e.w = n
m.s = g
b.s = g
c.z = m
c.v = b
k.s = c
n.w = e
assert m.s.v.s.v.s.z.s.txt == "c"