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

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

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

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

b.w = e
b.t = f
f.w = e
f.u = e
a.q = b
e.w = b
e.t = f
assert b.t.w.t.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: B = None
        self.txt = txt

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

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

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

b.w = e
b.t = f
f.w = e
f.u = e
a.q = b
e.w = b
e.t = f
assert b.t.w.t.w.txt == "e"