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

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

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

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

b = A("b")
m = B("m")
j = C("j")
a = D("a")
k = B("k")
f = B("f")
i = A("i")
e = C("e")

b.r = j
b.y = i
b.u = a
m.o = k
j.s = k
a.o = e
a.t = e
a.u = e
a.q = k
k.o = m
f.o = k
i.r = j
i.y = b
i.u = a
e.s = m
assert j.s.o.o.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.y: A = None
        self.u: D = None
        self.txt = txt

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

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

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

b = A("b")
m = B("m")
j = C("j")
a = D("a")
k = B("k")
f = B("f")
i = A("i")
e = C("e")

b.r = j
b.y = i
b.u = a
m.o = k
j.s = k
a.o = e
a.t = e
a.u = e
a.q = k
k.o = m
f.o = k
i.r = j
i.y = b
i.u = a
e.s = m
assert j.s.o.o.o.o.o.o.o.txt == "m"