class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: D = None
        self.y: 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.t: A = None
        self.o: A = None
        self.x: D = None
        self.w: C = None
        self.txt = txt

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

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

m.p = f
m.o = f
m.y = i
e.w = h
j.t = m
j.o = m
j.x = f
j.w = i
f.q = m
d.t = m
d.o = m
d.x = f
d.w = i
i.t = m
i.o = m
i.x = f
i.w = d
h.w = e
assert i.t.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.o: D = None
        self.y: 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.t: A = None
        self.o: A = None
        self.x: D = None
        self.w: C = None
        self.txt = txt

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

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

m.p = f
m.o = f
m.y = i
e.w = h
j.t = m
j.o = m
j.x = f
j.w = i
f.q = m
d.t = m
d.o = m
d.x = f
d.w = i
i.t = m
i.o = m
i.x = f
i.w = d
h.w = e
assert i.t.o.q.txt == "m"