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

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

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

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

d = A("d")
a = B("a")
n = C("n")
f = D("f")
b = A("b")
c = B("c")
i = C("i")

d.t = n
d.s = i
d.o = i
d.w = f
a.o = f
a.w = n
a.z = n
a.q = c
n.w = b
f.y = d
f.s = d
f.q = n
f.p = b
b.t = i
b.s = i
b.o = n
b.w = f
c.o = f
c.w = i
c.z = n
c.q = a
i.w = b
assert a.q.o.y.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.s: C = None
        self.o: C = None
        self.w: D = None
        self.txt = txt

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

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

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

d = A("d")
a = B("a")
n = C("n")
f = D("f")
b = A("b")
c = B("c")
i = C("i")

d.t = n
d.s = i
d.o = i
d.w = f
a.o = f
a.w = n
a.z = n
a.q = c
n.w = b
f.y = d
f.s = d
f.q = n
f.p = b
b.t = i
b.s = i
b.o = n
b.w = f
c.o = f
c.w = i
c.z = n
c.q = a
i.w = b
assert a.q.o.y.o.w.txt == "b"