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

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

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

k = A("k")
g = B("g")
j = C("j")
h = A("h")
i = B("i")
e = A("e")

k.o = g
g.x = i
g.p = i
g.z = j
j.t = h
j.r = k
j.o = g
h.o = g
i.x = g
i.p = g
i.z = j
e.o = g
assert g.z.r.o.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

k = A("k")
g = B("g")
j = C("j")
h = A("h")
i = B("i")
e = A("e")

k.o = g
g.x = i
g.p = i
g.z = j
j.t = h
j.r = k
j.o = g
h.o = g
i.x = g
i.p = g
i.z = j
e.o = g
assert g.z.r.o.x.x.txt == "g"