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

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.y: C = None
        self.x: A = None
        self.txt = txt

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

l = A("l")
k = B("k")
j = C("j")
a = D("a")
d = C("d")

l.p = k
l.o = k
l.w = d
l.y = a
k.x = d
k.z = a
j.w = l
j.u = l
j.x = l
j.y = d
a.o = k
a.t = k
a.p = l
a.v = j
d.w = l
d.u = l
d.x = l
d.y = j
assert a.o.x.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: C = None
        self.y: D = None
        self.o: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.y: C = None
        self.x: A = None
        self.txt = txt

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

l = A("l")
k = B("k")
j = C("j")
a = D("a")
d = C("d")

l.p = k
l.o = k
l.w = d
l.y = a
k.x = d
k.z = a
j.w = l
j.u = l
j.x = l
j.y = d
a.o = k
a.t = k
a.p = l
a.v = j
d.w = l
d.u = l
d.x = l
d.y = j
assert a.o.x.y.y.txt == "d"