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

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

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

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

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

n.q = b
n.p = k
n.x = a
g.y = a
g.o = a
g.v = n
l.o = g
l.r = e
l.v = b
b.t = g
b.s = l
k.q = b
k.p = n
k.x = g
e.o = a
e.r = l
e.v = b
a.y = g
a.o = g
a.v = n
assert k.x.o.v.p.x.o.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.p: A = None
        self.x: B = None
        self.txt = txt

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

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

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

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

n.q = b
n.p = k
n.x = a
g.y = a
g.o = a
g.v = n
l.o = g
l.r = e
l.v = b
b.t = g
b.s = l
k.q = b
k.p = n
k.x = g
e.o = a
e.r = l
e.v = b
a.y = g
a.o = g
a.v = n
assert k.x.o.v.p.x.o.txt == "a"