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

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

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

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

k = A("k")
g = B("g")
b = C("b")
m = D("m")
c = D("c")
e = C("e")
f = D("f")
l = C("l")
d = D("d")

k.o = g
g.x = b
g.v = m
g.w = k
b.o = g
b.p = k
b.x = k
m.x = c
m.s = b
m.z = e
c.x = f
c.s = b
c.z = l
e.o = g
e.p = k
e.x = k
f.x = d
f.s = b
f.z = b
l.o = g
l.p = k
l.x = k
d.x = f
d.s = b
d.z = l
assert k.o.w.o.w.o.x.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

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

k = A("k")
g = B("g")
b = C("b")
m = D("m")
c = D("c")
e = C("e")
f = D("f")
l = C("l")
d = D("d")

k.o = g
g.x = b
g.v = m
g.w = k
b.o = g
b.p = k
b.x = k
m.x = c
m.s = b
m.z = e
c.x = f
c.s = b
c.z = l
e.o = g
e.p = k
e.x = k
f.x = d
f.s = b
f.z = b
l.o = g
l.p = k
l.x = k
d.x = f
d.s = b
d.z = l
assert k.o.w.o.w.o.x.p.o.txt == "g"