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

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

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

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

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

n.o = i
f.u = i
f.s = b
f.r = k
k.z = n
h.q = f
h.w = k
h.s = b
b.o = i
i.q = f
i.w = k
i.s = b
assert h.s.o.q.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.txt = txt

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

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

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

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

n.o = i
f.u = i
f.s = b
f.r = k
k.z = n
h.q = f
h.w = k
h.s = b
b.o = i
i.q = f
i.w = k
i.s = b
assert h.s.o.q.u.txt == "i"