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

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

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

b = A("b")
i = B("i")
m = C("m")
h = A("h")
c = A("c")
d = C("d")
j = C("j")
e = B("e")
g = B("g")
a = C("a")

b.y = m
i.w = c
i.p = j
m.v = g
m.y = j
h.y = d
c.y = a
d.v = g
d.y = m
j.v = i
j.y = m
e.w = h
e.p = a
g.w = c
g.p = m
a.v = g
a.y = d
assert i.p.v.p.y.y.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

b = A("b")
i = B("i")
m = C("m")
h = A("h")
c = A("c")
d = C("d")
j = C("j")
e = B("e")
g = B("g")
a = C("a")

b.y = m
i.w = c
i.p = j
m.v = g
m.y = j
h.y = d
c.y = a
d.v = g
d.y = m
j.v = i
j.y = m
e.w = h
e.p = a
g.w = c
g.p = m
a.v = g
a.y = d
assert i.p.v.p.y.y.y.v.txt == "g"