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

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: A = None
        self.p: B = None
        self.y: D = None
        self.txt = txt

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

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

e.p = h
e.u = j
e.z = j
e.q = j
j.u = b
j.z = b
j.r = b
b.z = e
b.u = e
b.p = j
b.y = h
h.p = j
h.o = j
h.x = e
h.t = b
assert j.z.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.u: B = None
        self.z: B = None
        self.q: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: C = None
        self.z: C = None
        self.r: C = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: A = None
        self.p: B = None
        self.y: D = None
        self.txt = txt

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

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

e.p = h
e.u = j
e.z = j
e.q = j
j.u = b
j.z = b
j.r = b
b.z = e
b.u = e
b.p = j
b.y = h
h.p = j
h.o = j
h.x = e
h.t = b
assert j.z.y.t.txt == "b"