class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.u: E = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

g = A("g")
i = B("i")
j = C("j")
d = D("d")
f = E("f")
k = F("k")
h = D("h")

g.t = k
g.u = f
g.v = h
i.z = j
i.p = j
i.o = f
i.s = k
i.t = k
j.p = h
d.r = h
f.p = j
k.r = h
h.r = d
assert k.r.r.r.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.u: E = None
        self.v: D = None
        self.txt = txt

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

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

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

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

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

g = A("g")
i = B("i")
j = C("j")
d = D("d")
f = E("f")
k = F("k")
h = D("h")

g.t = k
g.u = f
g.v = h
i.z = j
i.p = j
i.o = f
i.s = k
i.t = k
j.p = h
d.r = h
f.p = j
k.r = h
h.r = d
assert k.r.r.r.r.r.r.r.txt == "h"