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

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

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

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

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

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

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

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

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

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

e.p = f
f.o = m
d.y = m
d.u = b
d.q = j
b.p = n
b.v = e
m.y = h
m.u = i
m.q = j
j.o = m
i.p = e
i.v = n
n.p = f
h.y = m
h.u = i
h.q = j
assert b.v.p.o.y.q.o.q.txt == "j"