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

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

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

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

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

h.v = i
h.p = n
b.u = i
b.y = d
i.y = m
i.x = e
i.p = e
i.z = d
d.y = i
d.u = n
d.r = n
f.u = n
f.y = d
e.u = n
e.y = d
j.v = n
j.p = i
m.v = n
m.p = i
n.y = h
n.x = e
n.z = d
n.p = b
l.v = n
l.p = n
assert n.z.y.y.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

h.v = i
h.p = n
b.u = i
b.y = d
i.y = m
i.x = e
i.p = e
i.z = d
d.y = i
d.u = n
d.r = n
f.u = n
f.y = d
e.u = n
e.y = d
j.v = n
j.p = i
m.v = n
m.p = i
n.y = h
n.x = e
n.z = d
n.p = b
l.v = n
l.p = n
assert n.z.y.y.p.p.y.txt == "d"