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

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

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

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

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

e.s = n
e.r = c
c.o = g
c.q = n
c.w = e
d.u = h
d.w = c
h.o = e
n.u = h
n.w = c
g.u = h
g.w = c
assert d.w.q.u.o.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.r: B = None
        self.txt = txt

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

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

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

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

e.s = n
e.r = c
c.o = g
c.q = n
c.w = e
d.u = h
d.w = c
h.o = e
n.u = h
n.w = c
g.u = h
g.w = c
assert d.w.q.u.o.r.q.txt == "n"