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

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

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

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

l = A("l")
m = B("m")
e = C("e")
b = D("b")
j = A("j")
h = B("h")
i = D("i")

l.s = j
m.q = h
e.p = l
e.u = l
e.t = b
b.s = m
b.t = h
b.r = e
j.s = l
h.q = m
i.s = m
i.t = h
i.r = e
assert i.t.q.q.q.q.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.s: A = None
        self.txt = txt

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

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

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

l = A("l")
m = B("m")
e = C("e")
b = D("b")
j = A("j")
h = B("h")
i = D("i")

l.s = j
m.q = h
e.p = l
e.u = l
e.t = b
b.s = m
b.t = h
b.r = e
j.s = l
h.q = m
i.s = m
i.t = h
i.r = e
assert i.t.q.q.q.q.q.q.txt == "h"