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

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

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

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

j = A("j")
e = B("e")
l = C("l")
i = D("i")
d = A("d")

j.o = d
j.x = d
j.q = e
j.p = e
e.p = l
e.q = l
e.w = j
l.z = j
l.x = j
l.t = i
i.w = l
i.s = e
i.o = e
d.o = j
d.x = j
d.q = e
d.p = e
assert j.p.q.t.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.q: B = None
        self.p: B = None
        self.x: A = None
        self.txt = txt

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

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

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

j = A("j")
e = B("e")
l = C("l")
i = D("i")
d = A("d")

j.o = d
j.x = d
j.q = e
j.p = e
e.p = l
e.q = l
e.w = j
l.z = j
l.x = j
l.t = i
i.w = l
i.s = e
i.o = e
d.o = j
d.x = j
d.q = e
d.p = e
assert j.p.q.t.o.p.txt == "l"