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

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

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

j = A("j")
d = B("d")
a = C("a")
e = A("e")
m = B("m")

j.t = e
j.s = e
d.q = a
d.u = a
d.v = j
a.u = j
e.t = j
e.s = j
m.q = a
m.u = a
m.v = j
assert m.v.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.s: A = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
a = C("a")
e = A("e")
m = B("m")

j.t = e
j.s = e
d.q = a
d.u = a
d.v = j
a.u = j
e.t = j
e.s = j
m.q = a
m.u = a
m.v = j
assert m.v.t.s.txt == "j"