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

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

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

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

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

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

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

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

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

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

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