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

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

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

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

c.o = h
b.z = h
b.w = k
j.y = h
i.o = c
f.y = k
h.o = i
n.y = k
k.o = c
e.y = k
assert c.o.o.o.o.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.z: A = None
        self.w: A = None
        self.txt = txt

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

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

c.o = h
b.z = h
b.w = k
j.y = h
i.o = c
f.y = k
h.o = i
n.y = k
k.o = c
e.y = k
assert c.o.o.o.o.o.o.o.o.txt == "i"