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

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

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

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

b = A("b")
i = B("i")
a = C("a")
n = D("n")
l = C("l")
m = D("m")
f = B("f")
g = D("g")

b.y = g
b.s = g
b.z = i
b.w = a
i.z = b
a.o = i
a.w = b
a.s = b
a.p = m
n.q = l
n.w = g
n.y = i
n.r = m
l.o = f
l.w = b
l.s = b
l.p = m
m.q = l
m.w = n
m.r = n
m.y = i
f.z = b
g.q = l
g.w = m
g.r = m
g.y = i
assert g.r.q.s.y.q.s.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.z: B = None
        self.s: D = None
        self.w: C = None
        self.txt = txt

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

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

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

b = A("b")
i = B("i")
a = C("a")
n = D("n")
l = C("l")
m = D("m")
f = B("f")
g = D("g")

b.y = g
b.s = g
b.z = i
b.w = a
i.z = b
a.o = i
a.w = b
a.s = b
a.p = m
n.q = l
n.w = g
n.y = i
n.r = m
l.o = f
l.w = b
l.s = b
l.p = m
m.q = l
m.w = n
m.r = n
m.y = i
f.z = b
g.q = l
g.w = m
g.r = m
g.y = i
assert g.r.q.s.y.q.s.w.txt == "a"