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

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

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

a = A("a")
b = B("b")
i = C("i")
g = C("g")
j = C("j")
k = B("k")

a.p = j
b.z = i
b.t = g
b.o = k
i.v = a
i.z = j
g.v = a
g.z = i
j.v = a
j.z = g
k.z = g
k.t = g
k.o = b
assert b.z.z.v.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

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

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

a = A("a")
b = B("b")
i = C("i")
g = C("g")
j = C("j")
k = B("k")

a.p = j
b.z = i
b.t = g
b.o = k
i.v = a
i.z = j
g.v = a
g.z = i
j.v = a
j.z = g
k.z = g
k.t = g
k.o = b
assert b.z.z.v.p.v.txt == "a"