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

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

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

h = A("h")
f = B("f")
e = C("e")
j = C("j")
n = B("n")
b = A("b")

h.w = f
h.u = e
f.y = h
f.u = h
f.r = n
e.v = b
e.o = b
e.w = f
j.v = b
j.w = f
j.o = h
n.y = h
n.r = f
n.u = b
b.w = f
b.u = j
assert b.u.v.w.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: B = None
        self.u: C = None
        self.txt = txt

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

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

h = A("h")
f = B("f")
e = C("e")
j = C("j")
n = B("n")
b = A("b")

h.w = f
h.u = e
f.y = h
f.u = h
f.r = n
e.v = b
e.o = b
e.w = f
j.v = b
j.w = f
j.o = h
n.y = h
n.r = f
n.u = b
b.w = f
b.u = j
assert b.u.v.w.r.r.txt == "f"