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

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

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

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

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

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

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

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

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

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

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