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

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: A = None
        self.w: A = None
        self.txt = txt

e = A("e")
f = B("f")
h = C("h")
k = C("k")
j = B("j")
l = C("l")
a = A("a")
m = B("m")

e.q = k
f.s = m
h.v = l
h.p = a
h.w = a
k.v = h
k.p = a
k.w = a
j.s = m
l.v = k
l.p = a
l.w = a
a.q = h
m.s = f
assert j.s.s.s.s.s.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: A = None
        self.w: A = None
        self.txt = txt

e = A("e")
f = B("f")
h = C("h")
k = C("k")
j = B("j")
l = C("l")
a = A("a")
m = B("m")

e.q = k
f.s = m
h.v = l
h.p = a
h.w = a
k.v = h
k.p = a
k.w = a
j.s = m
l.v = k
l.p = a
l.w = a
a.q = h
m.s = f
assert j.s.s.s.s.s.s.s.s.txt == "f"