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

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

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

i = A("i")
n = B("n")
j = C("j")
h = B("h")
f = C("f")
a = C("a")
d = A("d")
e = C("e")
c = C("c")

i.o = h
i.y = n
n.z = h
n.r = h
n.p = a
j.w = f
j.p = n
h.z = n
h.r = n
h.p = f
f.w = a
f.p = n
a.w = f
a.p = h
d.o = h
d.y = h
e.w = f
e.p = h
c.w = f
c.p = n
assert n.p.w.w.w.w.p.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
j = C("j")
h = B("h")
f = C("f")
a = C("a")
d = A("d")
e = C("e")
c = C("c")

i.o = h
i.y = n
n.z = h
n.r = h
n.p = a
j.w = f
j.p = n
h.z = n
h.r = n
h.p = f
f.w = a
f.p = n
a.w = f
a.p = h
d.o = h
d.y = h
e.w = f
e.p = h
c.w = f
c.p = n
assert n.p.w.w.w.w.p.r.p.w.txt == "f"