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

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

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

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

n = A("n")
c = B("c")
b = C("b")
a = D("a")
g = C("g")

n.u = c
n.t = c
n.z = a
n.w = a
c.o = g
c.q = n
c.v = n
c.z = a
b.w = a
a.q = b
g.w = a
assert a.q.w.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: D = None
        self.w: D = None
        self.t: B = None
        self.txt = txt

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

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

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

n = A("n")
c = B("c")
b = C("b")
a = D("a")
g = C("g")

n.u = c
n.t = c
n.z = a
n.w = a
c.o = g
c.q = n
c.v = n
c.z = a
b.w = a
a.q = b
g.w = a
assert a.q.w.q.w.txt == "a"