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

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

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

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

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

j.r = n
e.z = a
e.y = n
n.s = j
k.t = m
i.t = m
d.s = j
m.t = k
a.z = e
a.y = d
b.z = e
b.y = n
assert m.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

j.r = n
e.z = a
e.y = n
n.s = j
k.t = m
i.t = m
d.s = j
m.t = k
a.z = e
a.y = d
b.z = e
b.y = n
assert m.t.t.t.t.t.t.txt == "m"