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

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

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

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

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

b.s = k
b.q = d
b.p = d
b.z = f
f.z = c
f.u = k
f.w = m
e.v = k
e.t = h
e.y = h
e.r = f
m.o = j
m.r = c
n.v = d
n.t = e
n.y = e
n.r = f
h.v = k
h.t = e
h.r = f
h.y = n
j.o = c
j.r = c
c.o = j
c.r = m
k.s = d
k.p = d
k.q = b
k.z = f
d.s = k
d.p = k
d.q = b
d.z = f
assert m.r.o.r.o.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.q: A = None
        self.p: A = None
        self.z: B = None
        self.txt = txt

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

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

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

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

b.s = k
b.q = d
b.p = d
b.z = f
f.z = c
f.u = k
f.w = m
e.v = k
e.t = h
e.y = h
e.r = f
m.o = j
m.r = c
n.v = d
n.t = e
n.y = e
n.r = f
h.v = k
h.t = e
h.r = f
h.y = n
j.o = c
j.r = c
c.o = j
c.r = m
k.s = d
k.p = d
k.q = b
k.z = f
d.s = k
d.p = k
d.q = b
d.z = f
assert m.r.o.r.o.o.r.txt == "m"