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

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

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

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

d.w = h
d.o = h
e.x = i
i.x = k
h.w = d
h.o = d
c.x = i
k.x = g
g.x = e
assert i.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.o: A = None
        self.txt = txt

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

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

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

d.w = h
d.o = h
e.x = i
i.x = k
h.w = d
h.o = d
c.x = i
k.x = g
g.x = e
assert i.x.x.x.x.x.x.x.txt == "e"