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

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
l = C("l")
i = D("i")
f = D("f")

j.t = l
h.q = l
h.w = i
h.p = i
l.z = j
i.p = j
i.r = l
i.s = f
f.p = j
f.r = l
f.s = i
assert j.t.z.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

j = A("j")
h = B("h")
l = C("l")
i = D("i")
f = D("f")

j.t = l
h.q = l
h.w = i
h.p = i
l.z = j
i.p = j
i.r = l
i.s = f
f.p = j
f.r = l
f.s = i
assert j.t.z.t.z.txt == "j"