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

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

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

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

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

d.p = g
d.u = n
d.y = k
d.x = m
j.v = g
j.r = n
j.p = f
g.u = n
g.w = n
g.x = e
n.t = g
n.x = j
n.r = k
m.v = g
m.r = n
m.p = j
k.p = g
k.u = n
k.y = e
k.x = f
e.p = g
e.u = n
e.y = k
e.x = f
f.v = g
f.r = n
f.p = m
assert m.r.t.x.p.x.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: D = None
        self.y: A = None
        self.x: B = None
        self.txt = txt

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

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

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

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

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