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

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

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

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

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

b.t = e
b.u = f
f.s = e
f.x = i
i.q = f
i.w = f
i.o = b
e.x = f
h.q = f
h.w = f
h.o = b
assert e.x.s.x.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: B = None
        self.txt = txt

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

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

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

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

b.t = e
b.u = f
f.s = e
f.x = i
i.q = f
i.w = f
i.o = b
e.x = f
h.q = f
h.w = f
h.o = b
assert e.x.s.x.x.w.txt == "f"