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

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

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

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

c = A("c")
g = B("g")
m = C("m")
e = D("e")
d = D("d")
n = C("n")
a = D("a")

c.s = n
c.q = m
g.w = m
g.t = c
m.z = c
m.v = d
e.s = g
e.u = g
e.o = g
d.s = g
d.u = g
d.o = g
n.z = c
n.v = e
a.s = g
a.u = g
a.o = g
assert e.o.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.q: C = None
        self.txt = txt

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

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

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

c = A("c")
g = B("g")
m = C("m")
e = D("e")
d = D("d")
n = C("n")
a = D("a")

c.s = n
c.q = m
g.w = m
g.t = c
m.z = c
m.v = d
e.s = g
e.u = g
e.o = g
d.s = g
d.u = g
d.o = g
n.z = c
n.v = e
a.s = g
a.u = g
a.o = g
assert e.o.w.z.txt == "c"