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

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

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

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

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

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

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

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

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

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

b.r = a
b.q = a
b.y = g
b.w = g
f.r = b
f.s = n
i.z = m
i.t = k
c.v = f
c.q = d
c.o = n
c.w = m
g.r = b
g.s = c
d.r = k
d.s = c
m.z = i
m.t = b
a.z = m
a.t = b
n.v = d
n.q = f
n.o = c
n.w = a
k.r = a
k.q = i
k.y = d
k.w = g
assert d.s.q.s.o.w.t.txt == "b"