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

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

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

j = A("j")
b = B("b")
g = C("g")
d = A("d")
i = B("i")

j.t = d
j.y = d
b.w = d
b.v = j
b.q = i
g.t = d
d.t = j
d.y = j
i.w = d
i.v = j
i.q = b
assert i.v.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.y: A = None
        self.txt = txt

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

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

j = A("j")
b = B("b")
g = C("g")
d = A("d")
i = B("i")

j.t = d
j.y = d
b.w = d
b.v = j
b.q = i
g.t = d
d.t = j
d.y = j
i.w = d
i.v = j
i.q = b
assert i.v.y.t.txt == "j"