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

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

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

c = A("c")
h = B("h")
j = C("j")
a = C("a")
b = A("b")

c.w = j
c.x = h
h.v = b
h.u = b
h.o = c
j.o = h
j.r = c
a.o = h
a.r = c
b.w = j
b.x = h
assert b.x.o.x.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.x: B = None
        self.txt = txt

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

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

c = A("c")
h = B("h")
j = C("j")
a = C("a")
b = A("b")

c.w = j
c.x = h
h.v = b
h.u = b
h.o = c
j.o = h
j.r = c
a.o = h
a.r = c
b.w = j
b.x = h
assert b.x.o.x.o.x.txt == "h"