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

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

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

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

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

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

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

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

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