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

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

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

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

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

b.t = i
i.w = h
i.x = b
i.z = b
e.t = b
e.p = h
h.q = b
h.p = b
h.v = i
h.t = i
assert h.t.x.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

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

b.t = i
i.w = h
i.x = b
i.z = b
e.t = b
e.p = h
h.q = b
h.p = b
h.v = i
h.t = i
assert h.t.x.t.w.txt == "h"