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

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

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

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

l = A("l")
i = B("i")
a = C("a")
b = D("b")
m = A("m")
k = B("k")

l.o = b
l.p = i
i.w = a
i.x = a
i.q = k
a.z = i
a.o = b
a.w = b
a.r = m
b.q = l
m.o = b
m.p = k
k.w = a
k.x = a
k.q = i
assert b.q.p.q.w.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.p: B = None
        self.txt = txt

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

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

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

l = A("l")
i = B("i")
a = C("a")
b = D("b")
m = A("m")
k = B("k")

l.o = b
l.p = i
i.w = a
i.x = a
i.q = k
a.z = i
a.o = b
a.w = b
a.r = m
b.q = l
m.o = b
m.p = k
k.w = a
k.x = a
k.q = i
assert b.q.p.q.w.w.q.txt == "l"