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

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

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

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

a = A("a")
g = B("g")
j = C("j")
i = D("i")
l = A("l")
c = B("c")

a.p = i
a.y = i
a.z = l
a.s = c
g.o = j
j.w = i
j.r = a
i.u = j
i.s = g
i.r = c
i.v = a
l.p = i
l.y = i
l.z = a
l.s = g
c.o = j
assert l.p.v.y.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: D = None
        self.y: D = None
        self.z: A = None
        self.s: B = None
        self.txt = txt

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

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

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

a = A("a")
g = B("g")
j = C("j")
i = D("i")
l = A("l")
c = B("c")

a.p = i
a.y = i
a.z = l
a.s = c
g.o = j
j.w = i
j.r = a
i.u = j
i.s = g
i.r = c
i.v = a
l.p = i
l.y = i
l.z = a
l.s = g
c.o = j
assert l.p.v.y.v.p.v.txt == "a"