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

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

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

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

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

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

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

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

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

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

n.q = b
n.x = b
n.w = a
n.v = d
d.y = b
d.p = b
d.v = g
d.z = n
g.x = d
b.o = a
b.u = d
c.q = b
c.x = b
c.w = a
c.v = a
a.y = b
a.p = b
a.v = g
a.z = n
assert b.o.v.x.txt == "d"