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

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

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

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

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

j.w = m
j.p = n
j.t = a
e.r = n
e.z = f
e.p = h
m.z = h
m.p = b
d.u = e
f.u = n
h.u = e
n.r = e
n.z = d
n.p = f
i.w = m
i.p = n
i.t = j
b.z = f
b.p = m
a.w = b
a.p = e
a.t = i
assert m.z.u.z.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: B = None
        self.t: A = None
        self.txt = txt

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

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

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

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

j.w = m
j.p = n
j.t = a
e.r = n
e.z = f
e.p = h
m.z = h
m.p = b
d.u = e
f.u = n
h.u = e
n.r = e
n.z = d
n.p = f
i.w = m
i.p = n
i.t = j
b.z = f
b.p = m
a.w = b
a.p = e
a.t = i
assert m.z.u.z.txt == "f"