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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: D = None
        self.txt = txt

d = A("d")
a = B("a")
h = C("h")
b = D("b")
n = E("n")
c = D("c")
l = D("l")
m = D("m")
f = C("f")
k = E("k")

d.p = c
d.u = a
d.v = a
a.u = f
a.q = c
a.y = b
h.q = k
h.o = d
h.u = a
b.x = a
n.v = b
n.z = l
c.x = a
l.x = a
m.x = a
f.q = k
f.o = d
f.u = a
k.v = m
k.z = b
assert a.q.x.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: B = None
        self.v: B = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: D = None
        self.txt = txt

d = A("d")
a = B("a")
h = C("h")
b = D("b")
n = E("n")
c = D("c")
l = D("l")
m = D("m")
f = C("f")
k = E("k")

d.p = c
d.u = a
d.v = a
a.u = f
a.q = c
a.y = b
h.q = k
h.o = d
h.u = a
b.x = a
n.v = b
n.z = l
c.x = a
l.x = a
m.x = a
f.q = k
f.o = d
f.u = a
k.v = m
k.z = b
assert a.q.x.u.txt == "f"