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

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

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

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

e.y = m
e.q = a
j.t = b
j.v = m
m.s = b
b.t = a
b.v = m
a.t = j
a.v = m
f.y = m
f.q = b
assert j.v.s.v.s.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.q: B = None
        self.txt = txt

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

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

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

e.y = m
e.q = a
j.t = b
j.v = m
m.s = b
b.t = a
b.v = m
a.t = j
a.v = m
f.y = m
f.q = b
assert j.v.s.v.s.v.txt == "m"