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

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: D = None
        self.s: A = None
        self.txt = txt

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

m.u = n
m.x = f
m.y = e
m.z = a
j.x = f
j.v = b
j.z = n
j.t = g
e.q = b
h.u = b
h.q = g
h.s = m
g.u = b
g.q = h
g.s = n
n.u = m
n.x = b
n.y = e
n.z = d
a.q = b
d.q = j
f.x = j
f.v = j
f.z = n
f.t = g
b.x = j
b.v = f
b.z = m
b.t = h
assert a.q.x.v.v.v.v.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.x: B = None
        self.y: C = None
        self.z: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.u: B = None
        self.q: D = None
        self.s: A = None
        self.txt = txt

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

m.u = n
m.x = f
m.y = e
m.z = a
j.x = f
j.v = b
j.z = n
j.t = g
e.q = b
h.u = b
h.q = g
h.s = m
g.u = b
g.q = h
g.s = n
n.u = m
n.x = b
n.y = e
n.z = d
a.q = b
d.q = j
f.x = j
f.v = j
f.z = n
f.t = g
b.x = j
b.v = f
b.z = m
b.t = h
assert a.q.x.v.v.v.v.v.x.txt == "j"