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

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

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

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

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

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

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

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

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

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

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