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

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

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

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

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

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

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

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

g.y = b
n.s = e
m.w = i
m.v = k
c.w = i
c.v = k
b.w = g
b.v = k
f.y = k
e.s = n
i.y = c
k.w = g
k.v = c
assert m.w.y.v.w.y.w.txt == "g"