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

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

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

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

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

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

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

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

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

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

b.o = d
b.p = e
d.t = j
d.u = b
j.u = a
h.o = j
h.q = d
m.o = j
m.q = d
a.t = j
a.u = b
e.o = a
e.p = n
n.o = d
n.p = e
i.u = a
assert e.o.u.p.txt == "e"