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

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

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

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

k.o = a
k.u = h
e.p = f
c.v = k
c.w = a
f.o = a
f.u = h
h.p = f
a.p = k
assert c.w.p.o.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: B = None
        self.txt = txt

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

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

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

k.o = a
k.u = h
e.p = f
c.v = k
c.w = a
f.o = a
f.u = h
h.p = f
a.p = k
assert c.w.p.o.p.o.txt == "a"