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

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

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

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

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

k.q = c
k.v = m
g.s = h
g.w = i
g.v = e
i.q = m
i.u = b
l.r = b
h.r = b
e.r = d
b.q = c
b.v = k
d.q = c
d.v = k
m.q = g
m.v = b
c.s = e
c.w = i
c.v = h
assert e.r.q.s.r.v.q.s.r.q.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: A = None
        self.txt = txt

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

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

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

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

k.q = c
k.v = m
g.s = h
g.w = i
g.v = e
i.q = m
i.u = b
l.r = b
h.r = b
e.r = d
b.q = c
b.v = k
d.q = c
d.v = k
m.q = g
m.v = b
c.s = e
c.w = i
c.v = h
assert e.r.q.s.r.v.q.s.r.q.w.txt == "i"