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

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

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

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

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

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

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

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

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

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

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