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

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

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

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

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

e.u = h
e.x = h
e.t = h
h.w = j
h.q = e
d.y = h
d.t = h
j.q = d
assert h.q.u.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: B = None
        self.t: B = None
        self.txt = txt

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

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

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

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

e.u = h
e.x = h
e.t = h
h.w = j
h.q = e
d.y = h
d.t = h
j.q = d
assert h.q.u.w.txt == "j"