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

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

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

d = A("d")
k = B("k")
h = C("h")

d.o = k
d.y = h
k.w = d
k.p = d
h.u = k
assert k.p.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.txt = txt

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

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

d = A("d")
k = B("k")
h = C("h")

d.o = k
d.y = h
k.w = d
k.p = d
h.u = k
assert k.p.o.w.txt == "d"