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

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

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

c = A("c")
a = B("a")
h = C("h")
e = A("e")

c.y = h
a.q = e
a.o = e
a.p = h
h.w = c
h.r = c
e.y = h
assert a.q.y.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
h = C("h")
e = A("e")

c.y = h
a.q = e
a.o = e
a.p = h
h.w = c
h.r = c
e.y = h
assert a.q.y.w.y.txt == "h"