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

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

class C:
    def __init__(self, txt: str):
        self.v: G = None
        self.r: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.v: B = None
        self.w: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: D = None
        self.txt = txt

h = A("h")
c = B("c")
i = C("i")
f = D("f")
g = E("g")
n = F("n")
l = G("l")

h.q = f
c.t = f
i.v = l
i.r = n
f.s = i
g.x = n
g.w = n
g.v = c
n.w = f
l.v = f
l.o = f
assert n.w.s.r.w.s.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: G = None
        self.r: F = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.v: B = None
        self.w: F = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.v: D = None
        self.o: D = None
        self.txt = txt

h = A("h")
c = B("c")
i = C("i")
f = D("f")
g = E("g")
n = F("n")
l = G("l")

h.q = f
c.t = f
i.v = l
i.r = n
f.s = i
g.x = n
g.w = n
g.v = c
n.w = f
l.v = f
l.o = f
assert n.w.s.r.w.s.r.w.txt == "f"