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

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

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

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

m = A("m")
i = B("i")
l = C("l")
n = D("n")
e = D("e")
k = C("k")
d = A("d")
h = D("h")
g = B("g")

m.y = i
m.q = g
m.x = k
i.x = e
i.r = k
i.v = l
l.u = k
l.z = k
l.v = k
l.r = h
n.o = l
n.q = i
n.t = e
e.o = k
e.q = g
e.t = n
k.u = l
k.z = l
k.v = l
k.r = e
d.y = i
d.q = i
d.x = l
h.o = l
h.q = g
h.t = e
g.x = n
g.r = k
g.v = k
assert m.q.v.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: B = None
        self.x: C = None
        self.txt = txt

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

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

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

m = A("m")
i = B("i")
l = C("l")
n = D("n")
e = D("e")
k = C("k")
d = A("d")
h = D("h")
g = B("g")

m.y = i
m.q = g
m.x = k
i.x = e
i.r = k
i.v = l
l.u = k
l.z = k
l.v = k
l.r = h
n.o = l
n.q = i
n.t = e
e.o = k
e.q = g
e.t = n
k.u = l
k.z = l
k.v = l
k.r = e
d.y = i
d.q = i
d.x = l
h.o = l
h.q = g
h.t = e
g.x = n
g.r = k
g.v = k
assert m.q.v.r.txt == "e"