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

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

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

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

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

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

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

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

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

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

i.y = a
i.r = d
i.x = k
i.p = g
a.w = j
a.u = g
d.w = a
g.u = j
g.t = e
g.p = d
m.y = j
m.r = k
m.x = d
m.p = g
e.y = a
e.r = k
e.x = d
e.p = g
k.w = j
n.y = j
n.r = k
n.x = d
n.p = g
j.w = a
j.u = g
h.y = j
h.r = d
h.x = d
h.p = g
assert j.w.w.u.p.w.txt == "a"