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

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

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

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

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

k.u = g
k.z = d
g.o = c
g.q = e
g.s = k
g.x = k
d.y = g
d.r = g
c.v = d
c.t = e
n.o = c
n.q = c
n.s = k
n.x = k
e.v = d
e.t = c
assert n.q.v.r.q.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

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

k.u = g
k.z = d
g.o = c
g.q = e
g.s = k
g.x = k
d.y = g
d.r = g
c.v = d
c.t = e
n.o = c
n.q = c
n.s = k
n.x = k
e.v = d
e.t = c
assert n.q.v.r.q.v.y.txt == "g"