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

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

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

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

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

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

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

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

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

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

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