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

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

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

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

f = A("f")
a = B("a")
i = C("i")
d = D("d")
h = B("h")

f.u = d
f.z = i
f.o = i
a.t = i
a.u = h
a.r = d
i.z = f
i.x = f
i.w = h
i.y = d
d.s = h
d.r = f
h.t = i
h.u = a
h.r = d
assert a.u.r.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.z: C = None
        self.o: C = None
        self.txt = txt

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

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

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

f = A("f")
a = B("a")
i = C("i")
d = D("d")
h = B("h")

f.u = d
f.z = i
f.o = i
a.t = i
a.u = h
a.r = d
i.z = f
i.x = f
i.w = h
i.y = d
d.s = h
d.r = f
h.t = i
h.u = a
h.r = d
assert a.u.r.s.t.txt == "i"