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

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

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

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

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

b.z = m
b.v = k
h.r = b
d.y = g
d.o = c
d.v = k
j.q = c
j.p = b
j.z = m
m.q = g
m.p = b
m.z = j
k.y = h
k.o = c
k.v = d
n.y = c
n.o = c
n.v = d
g.r = b
i.q = c
i.p = b
i.z = m
c.r = b
assert m.q.r.v.y.r.z.p.v.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.v: C = None
        self.txt = txt

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

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

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

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

b.z = m
b.v = k
h.r = b
d.y = g
d.o = c
d.v = k
j.q = c
j.p = b
j.z = m
m.q = g
m.p = b
m.z = j
k.y = h
k.o = c
k.v = d
n.y = c
n.o = c
n.v = d
g.r = b
i.q = c
i.p = b
i.z = m
c.r = b
assert m.q.r.v.y.r.z.p.v.y.r.txt == "b"