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

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

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

f = A("f")
b = B("b")
d = C("d")
e = B("e")
j = A("j")

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

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

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

f = A("f")
b = B("b")
d = C("d")
e = B("e")
j = A("j")

f.t = b
f.s = j
b.w = e
d.w = f
d.r = j
d.s = j
e.w = b
j.t = b
j.s = f
assert j.s.s.t.w.txt == "e"