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

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

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

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

h = A("h")
b = B("b")
f = C("f")
l = D("l")
k = A("k")
e = A("e")
i = D("i")
c = A("c")
n = B("n")
m = C("m")

h.s = b
h.z = f
b.x = l
b.r = h
b.s = n
f.o = m
l.o = f
k.s = b
k.z = m
e.s = n
e.z = m
i.o = m
c.s = n
c.z = m
n.x = i
n.r = e
n.s = b
m.o = f
assert b.x.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
b = B("b")
f = C("f")
l = D("l")
k = A("k")
e = A("e")
i = D("i")
c = A("c")
n = B("n")
m = C("m")

h.s = b
h.z = f
b.x = l
b.r = h
b.s = n
f.o = m
l.o = f
k.s = b
k.z = m
e.s = n
e.z = m
i.o = m
c.s = n
c.z = m
n.x = i
n.r = e
n.s = b
m.o = f
assert b.x.o.o.o.o.o.txt == "f"