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

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

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

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

i.z = e
c.r = b
c.v = f
c.p = f
j.p = b
j.o = f
j.v = c
h.z = i
g.p = b
g.o = f
g.v = c
b.p = g
b.o = e
b.v = k
e.z = f
f.z = i
k.r = j
k.v = f
k.p = e
assert e.z.z.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

i.z = e
c.r = b
c.v = f
c.p = f
j.p = b
j.o = f
j.v = c
h.z = i
g.p = b
g.o = f
g.v = c
b.p = g
b.o = e
b.v = k
e.z = f
f.z = i
k.r = j
k.v = f
k.p = e
assert e.z.z.z.z.txt == "f"