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

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

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

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

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

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

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

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

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

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

e.o = d
m.w = b
m.x = i
m.y = g
d.p = j
d.t = m
a.u = i
a.o = i
a.p = m
b.o = d
j.u = a
j.o = a
j.p = g
h.p = i
h.t = m
g.w = n
g.x = a
g.y = m
i.u = j
i.o = j
i.p = m
n.o = d
assert j.u.p.w.o.txt == "d"