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

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

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

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

a = A("a")
i = B("i")
h = C("h")
k = D("k")
f = A("f")
b = A("b")
m = C("m")

a.r = i
i.w = a
i.r = m
i.o = k
i.t = h
h.r = i
h.z = k
h.s = b
k.x = h
k.z = b
k.p = a
f.r = i
b.r = i
m.r = i
m.z = k
m.s = b
assert f.r.r.s.r.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

a = A("a")
i = B("i")
h = C("h")
k = D("k")
f = A("f")
b = A("b")
m = C("m")

a.r = i
i.w = a
i.r = m
i.o = k
i.t = h
h.r = i
h.z = k
h.s = b
k.x = h
k.z = b
k.p = a
f.r = i
b.r = i
m.r = i
m.z = k
m.s = b
assert f.r.r.s.r.o.x.txt == "h"