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

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

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

a = A("a")
f = B("f")
h = C("h")
g = A("g")
e = C("e")

a.y = g
a.q = g
f.u = g
h.u = e
g.y = a
g.q = a
e.u = h
assert g.y.y.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.q: A = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
h = C("h")
g = A("g")
e = C("e")

a.y = g
a.q = g
f.u = g
h.u = e
g.y = a
g.q = a
e.u = h
assert g.y.y.q.txt == "a"