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.u: A = None
        self.o: C = None
        self.txt = txt

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

c = A("c")
f = B("f")
e = C("e")
h = A("h")

c.r = f
c.w = f
f.u = h
f.o = e
e.v = h
h.r = f
h.w = f
assert f.o.v.w.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.u: A = None
        self.o: C = None
        self.txt = txt

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

c = A("c")
f = B("f")
e = C("e")
h = A("h")

c.r = f
c.w = f
f.u = h
f.o = e
e.v = h
h.r = f
h.w = f
assert f.o.v.w.txt == "f"