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

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

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

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

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

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

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

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

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

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

a.v = d
a.x = d
n.t = b
n.v = e
n.p = h
b.y = e
b.r = m
l.p = b
l.z = n
d.v = h
d.x = h
h.v = e
h.x = d
m.t = b
m.v = e
m.p = a
e.v = d
e.x = a
i.p = b
i.z = n
assert e.x.x.x.v.v.x.v.x.txt == "a"