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

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

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

f = A("f")
d = B("d")
n = C("n")
h = C("h")

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

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

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

f = A("f")
d = B("d")
n = C("n")
h = C("h")

f.u = d
f.w = d
d.y = h
n.r = h
h.r = n
assert h.r.r.r.txt == "n"