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

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

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

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

g.t = h
g.y = a
g.w = a
h.o = f
a.w = h
a.q = h
a.p = h
f.t = h
f.y = a
f.w = a
assert h.o.y.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: C = None
        self.w: C = None
        self.txt = txt

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

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

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

g.t = h
g.y = a
g.w = a
h.o = f
a.w = h
a.q = h
a.p = h
f.t = h
f.y = a
f.w = a
assert h.o.y.p.txt == "h"