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

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

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

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

g = A("g")
e = B("e")
a = C("a")
j = D("j")
h = B("h")
n = A("n")
k = D("k")

g.o = j
g.q = a
e.o = k
e.q = h
e.v = n
e.s = a
a.x = e
a.r = e
a.w = e
a.p = j
j.u = a
j.z = k
h.o = k
h.q = e
h.v = g
h.s = a
n.o = k
n.q = a
k.u = a
k.z = j
assert a.w.q.v.txt == "
class A:
    def __init__(self, txt: str):
        self.o: D = None
        self.q: C = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
a = C("a")
j = D("j")
h = B("h")
n = A("n")
k = D("k")

g.o = j
g.q = a
e.o = k
e.q = h
e.v = n
e.s = a
a.x = e
a.r = e
a.w = e
a.p = j
j.u = a
j.z = k
h.o = k
h.q = e
h.v = g
h.s = a
n.o = k
n.q = a
k.u = a
k.z = j
assert a.w.q.v.txt == "g"