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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: C = None
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
a = C("a")
f = D("f")
d = B("d")
h = D("h")
e = D("e")
m = A("m")

c.q = d
c.y = d
c.p = h
c.o = f
i.q = e
i.o = a
i.z = a
a.y = e
f.q = d
f.v = c
f.w = c
d.q = h
d.o = a
d.z = a
h.q = i
h.v = c
h.w = m
e.q = d
e.v = c
e.w = m
m.q = i
m.y = i
m.p = e
m.o = h
assert c.p.v.o.w.y.q.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.p: D = None
        self.y: B = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.o: C = None
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
i = B("i")
a = C("a")
f = D("f")
d = B("d")
h = D("h")
e = D("e")
m = A("m")

c.q = d
c.y = d
c.p = h
c.o = f
i.q = e
i.o = a
i.z = a
a.y = e
f.q = d
f.v = c
f.w = c
d.q = h
d.o = a
d.z = a
h.q = i
h.v = c
h.w = m
e.q = d
e.v = c
e.w = m
m.q = i
m.y = i
m.p = e
m.o = h
assert c.p.v.o.w.y.q.w.o.txt == "h"