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

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

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

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

h = A("h")
k = B("k")
f = C("f")
e = D("e")
m = C("m")
j = D("j")
i = D("i")
n = C("n")

h.r = i
k.z = n
f.o = h
f.x = m
e.p = f
e.r = i
e.w = h
m.o = h
m.x = f
j.p = f
j.r = i
j.w = h
i.p = f
i.r = e
i.w = h
n.o = h
n.x = m
assert k.z.x.x.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

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

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

h = A("h")
k = B("k")
f = C("f")
e = D("e")
m = C("m")
j = D("j")
i = D("i")
n = C("n")

h.r = i
k.z = n
f.o = h
f.x = m
e.p = f
e.r = i
e.w = h
m.o = h
m.x = f
j.p = f
j.r = i
j.w = h
i.p = f
i.r = e
i.w = h
n.o = h
n.x = m
assert k.z.x.x.o.r.txt == "i"