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

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

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

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

h = A("h")
n = B("n")
i = C("i")
d = D("d")
j = C("j")
f = A("f")
c = A("c")
m = B("m")

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

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

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

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

h = A("h")
n = B("n")
i = C("i")
d = D("d")
j = C("j")
f = A("f")
c = A("c")
m = B("m")

h.w = d
h.p = d
h.r = c
h.u = n
n.y = d
n.x = i
n.t = m
i.p = f
i.y = f
i.t = d
d.u = i
j.p = f
j.t = d
j.y = c
f.w = d
f.p = d
f.r = c
f.u = m
c.w = d
c.p = d
c.r = f
c.u = n
m.y = d
m.x = j
m.t = n
assert c.u.t.t.t.y.u.p.txt == "f"