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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: E = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
j = C("j")
i = D("i")
d = E("d")
m = C("m")
f = D("f")
n = D("n")

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

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

class C:
    def __init__(self, txt: str):
        self.v: A = None
        self.y: E = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
j = C("j")
i = D("i")
d = E("d")
m = C("m")
f = D("f")
n = D("n")

b.o = i
b.q = n
b.w = f
a.p = j
a.o = m
a.r = f
j.v = b
j.y = d
i.p = d
i.q = n
d.u = a
d.v = b
m.v = b
m.y = d
f.p = d
f.q = i
n.p = d
n.q = i
assert f.p.u.p.txt == "j"