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

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: C = None
        self.p: C = None
        self.u: A = None
        self.txt = txt

h = A("h")
n = B("n")
i = C("i")
a = D("a")
j = B("j")
b = C("b")
e = C("e")
k = D("k")
l = D("l")
c = A("c")

h.o = k
n.o = j
n.v = c
n.p = a
i.u = k
a.x = b
a.z = b
a.p = b
a.u = h
j.o = n
j.v = h
j.p = l
b.u = a
e.u = l
k.x = b
k.z = b
k.p = i
k.u = h
l.x = b
l.z = b
l.p = e
l.u = h
c.o = l
assert c.o.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.x: C = None
        self.z: C = None
        self.p: C = None
        self.u: A = None
        self.txt = txt

h = A("h")
n = B("n")
i = C("i")
a = D("a")
j = B("j")
b = C("b")
e = C("e")
k = D("k")
l = D("l")
c = A("c")

h.o = k
n.o = j
n.v = c
n.p = a
i.u = k
a.x = b
a.z = b
a.p = b
a.u = h
j.o = n
j.v = h
j.p = l
b.u = a
e.u = l
k.x = b
k.z = b
k.p = i
k.u = h
l.x = b
l.z = b
l.p = e
l.u = h
c.o = l
assert c.o.u.o.u.txt == "h"