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

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

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

c = A("c")
d = B("d")
j = C("j")
f = A("f")

c.q = f
c.s = d
d.r = j
j.t = c
f.q = c
f.s = d
assert j.t.s.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: B = None
        self.txt = txt

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

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

c = A("c")
d = B("d")
j = C("j")
f = A("f")

c.q = f
c.s = d
d.r = j
j.t = c
f.q = c
f.s = d
assert j.t.s.r.txt == "j"