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

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

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

a = A("a")
g = B("g")
h = C("h")
e = C("e")
i = B("i")
m = A("m")
f = C("f")

a.w = g
g.y = m
g.v = m
g.s = i
h.q = g
h.y = a
e.q = g
e.y = m
i.y = a
i.v = a
i.s = g
m.w = i
f.q = i
f.y = a
assert e.y.w.s.v.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.txt = txt

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

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

a = A("a")
g = B("g")
h = C("h")
e = C("e")
i = B("i")
m = A("m")
f = C("f")

a.w = g
g.y = m
g.v = m
g.s = i
h.q = g
h.y = a
e.q = g
e.y = m
i.y = a
i.v = a
i.s = g
m.w = i
f.q = i
f.y = a
assert e.y.w.s.v.w.txt == "i"