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

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

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

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

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

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

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

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

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

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

n.p = g
f.q = c
f.t = c
a.r = d
a.y = m
a.x = m
a.v = k
m.u = a
m.x = c
m.s = c
m.w = n
c.q = f
c.t = f
g.p = n
k.u = d
k.x = f
k.s = f
k.w = n
e.u = d
e.x = f
e.s = f
e.w = n
d.r = a
d.y = e
d.v = m
d.x = k
assert d.r.v.u.x.u.txt == "d"