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

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

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

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

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

g.u = h
g.x = h
k.p = d
m.v = e
m.r = g
m.p = k
m.x = a
a.s = d
j.u = a
j.x = a
c.u = h
c.x = a
n.u = a
n.x = h
d.p = k
h.s = k
e.v = m
e.r = g
e.p = d
e.x = h
assert m.v.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.x: D = None
        self.txt = txt

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

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

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

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

g.u = h
g.x = h
k.p = d
m.v = e
m.r = g
m.p = k
m.x = a
a.s = d
j.u = a
j.x = a
c.u = h
c.x = a
n.u = a
n.x = h
d.p = k
h.s = k
e.v = m
e.r = g
e.p = d
e.x = h
assert m.v.p.p.txt == "k"