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

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

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

j = A("j")
h = B("h")
m = C("m")
c = B("c")
f = B("f")
e = C("e")
i = A("i")

j.o = i
h.v = m
h.x = j
h.o = f
m.p = f
m.t = f
c.v = e
c.x = i
c.o = f
f.v = e
f.x = j
f.o = h
e.p = h
e.t = h
i.o = j
assert c.v.p.x.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.txt = txt

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

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

j = A("j")
h = B("h")
m = C("m")
c = B("c")
f = B("f")
e = C("e")
i = A("i")

j.o = i
h.v = m
h.x = j
h.o = f
m.p = f
m.t = f
c.v = e
c.x = i
c.o = f
f.v = e
f.x = j
f.o = h
e.p = h
e.t = h
i.o = j
assert c.v.p.x.o.o.o.o.txt == "j"