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

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

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

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

j = A("j")
l = B("l")
m = C("m")
k = D("k")
b = D("b")
h = C("h")
c = C("c")
n = A("n")
a = C("a")

j.q = c
j.o = l
l.v = k
l.z = n
l.x = j
m.x = j
m.q = b
m.z = l
k.z = a
k.u = n
b.z = h
b.u = n
h.x = j
h.q = b
h.z = l
c.x = n
c.q = k
c.z = l
n.q = c
n.o = l
a.x = j
a.q = b
a.z = l
assert k.u.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.o: B = None
        self.txt = txt

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

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

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

j = A("j")
l = B("l")
m = C("m")
k = D("k")
b = D("b")
h = C("h")
c = C("c")
n = A("n")
a = C("a")

j.q = c
j.o = l
l.v = k
l.z = n
l.x = j
m.x = j
m.q = b
m.z = l
k.z = a
k.u = n
b.z = h
b.u = n
h.x = j
h.q = b
h.z = l
c.x = n
c.q = k
c.z = l
n.q = c
n.o = l
a.x = j
a.q = b
a.z = l
assert k.u.o.x.txt == "j"