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

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

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

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

j = A("j")
h = B("h")
d = C("d")
f = D("f")

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

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

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

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

j = A("j")
h = B("h")
d = C("d")
f = D("f")

j.o = f
j.x = f
j.t = d
h.w = j
h.s = j
d.o = f
d.s = h
f.u = h
assert j.t.o.u.txt == "h"