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

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

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

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

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

c.s = d
c.v = h
m.r = h
n.q = k
n.w = k
n.u = m
n.t = d
h.s = j
k.s = j
j.s = m
j.v = k
d.r = h
a.q = h
a.w = k
a.u = m
a.t = d
i.s = m
i.v = h
assert j.v.s.v.s.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.v: D = None
        self.txt = txt

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

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

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

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

c.s = d
c.v = h
m.r = h
n.q = k
n.w = k
n.u = m
n.t = d
h.s = j
k.s = j
j.s = m
j.v = k
d.r = h
a.q = h
a.w = k
a.u = m
a.t = d
i.s = m
i.v = h
assert j.v.s.v.s.txt == "j"