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

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

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

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

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

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

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

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

k.r = d
k.w = d
d.y = k
d.u = g
d.t = g
g.u = d
assert d.u.u.u.txt == "g"