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

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

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

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

g = A("g")
l = B("l")
m = C("m")
n = D("n")
k = C("k")
c = C("c")
f = A("f")

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

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

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

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

g = A("g")
l = B("l")
m = C("m")
n = D("n")
k = C("k")
c = C("c")
f = A("f")

g.o = l
g.v = l
g.q = l
g.p = m
l.y = k
l.s = n
l.x = f
m.p = k
m.u = n
m.z = n
n.y = k
n.u = c
n.r = l
k.p = c
k.u = n
k.z = n
c.p = k
c.u = n
c.z = n
f.o = l
f.v = l
f.q = l
f.p = m
assert k.z.r.y.p.p.txt == "k"