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

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

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

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

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

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

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

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

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

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

e.x = b
e.v = g
e.y = i
f.s = k
f.w = g
f.r = e
f.p = e
k.x = g
k.z = m
c.z = f
c.r = m
l.s = i
l.w = b
l.r = e
l.p = e
i.x = l
i.z = m
m.z = b
m.r = c
g.s = i
g.w = l
g.r = e
g.p = e
b.s = i
b.w = l
b.r = e
b.p = e
assert g.s.x.r.v.w.r.y.x.txt == "l"