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

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

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

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

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

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

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

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

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

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

d.r = n
d.y = h
d.v = h
d.w = h
n.r = h
n.p = h
n.t = b
m.o = d
m.y = n
m.r = b
h.p = m
h.u = n
b.o = d
b.y = n
b.r = m
e.o = d
e.y = n
e.r = b
f.o = i
f.y = n
f.r = m
i.r = n
i.y = h
i.v = h
i.w = h
assert d.r.p.p.o.r.r.u.txt == "n"