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

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

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

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

a = A("a")
n = B("n")
i = C("i")
e = D("e")
j = D("j")
f = C("f")
c = B("c")
k = A("k")
d = D("d")

a.z = f
a.v = n
a.y = c
n.p = c
n.r = d
n.s = j
n.q = k
i.y = a
e.o = n
e.x = j
j.o = n
j.x = d
f.y = k
c.p = n
c.r = d
c.s = d
c.q = a
k.z = i
k.v = n
k.y = n
d.o = c
d.x = e
assert e.x.x.x.o.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.v: B = None
        self.y: B = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
i = C("i")
e = D("e")
j = D("j")
f = C("f")
c = B("c")
k = A("k")
d = D("d")

a.z = f
a.v = n
a.y = c
n.p = c
n.r = d
n.s = j
n.q = k
i.y = a
e.o = n
e.x = j
j.o = n
j.x = d
f.y = k
c.p = n
c.r = d
c.s = d
c.q = a
k.z = i
k.v = n
k.y = n
d.o = c
d.x = e
assert e.x.x.x.o.q.txt == "k"