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

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

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

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

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

e.v = h
f.p = j
f.q = l
l.v = m
l.s = m
l.q = i
i.q = k
j.v = h
d.v = h
b.p = j
b.q = l
k.p = e
k.q = l
h.q = f
m.v = l
m.s = l
m.q = i
assert b.q.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

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

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

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

e.v = h
f.p = j
f.q = l
l.v = m
l.s = m
l.q = i
i.q = k
j.v = h
d.v = h
b.p = j
b.q = l
k.p = e
k.q = l
h.q = f
m.v = l
m.s = l
m.q = i
assert b.q.v.v.txt == "l"