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

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

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

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

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

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

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

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

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

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

k.v = g
k.p = g
k.x = l
k.y = f
h.z = a
h.q = b
h.p = n
l.r = a
l.s = f
b.q = g
b.o = g
b.s = g
g.v = k
g.p = k
g.x = l
g.y = f
a.z = n
a.q = b
a.p = h
f.q = g
f.o = g
f.s = k
n.z = a
n.p = a
n.q = f
assert k.y.q.x.s.o.txt == "g"