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

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.q: D = None
        self.s: B = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: F = None
        self.p: C = None
        self.t: F = None
        self.txt = txt

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

g = A("g")
b = B("b")
a = C("a")
d = D("d")
m = E("m")
i = F("i")
h = F("h")

g.s = i
g.p = i
g.v = a
b.r = g
a.u = i
a.q = d
a.s = b
a.r = b
a.p = g
d.q = b
d.s = a
m.o = a
m.p = a
m.y = i
m.t = i
i.w = h
h.w = i
assert i.w.w.w.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.s: F = None
        self.p: F = None
        self.v: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.u: F = None
        self.q: D = None
        self.s: B = None
        self.p: A = None
        self.r: B = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: F = None
        self.p: C = None
        self.t: F = None
        self.txt = txt

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

g = A("g")
b = B("b")
a = C("a")
d = D("d")
m = E("m")
i = F("i")
h = F("h")

g.s = i
g.p = i
g.v = a
b.r = g
a.u = i
a.q = d
a.s = b
a.r = b
a.p = g
d.q = b
d.s = a
m.o = a
m.p = a
m.y = i
m.t = i
i.w = h
h.w = i
assert i.w.w.w.w.w.w.txt == "i"