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

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

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

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

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

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

l = A("l")
g = B("g")
k = C("k")
n = D("n")
j = E("j")
h = F("h")
m = E("m")
c = A("c")
f = C("f")

l.q = g
l.s = g
l.u = k
g.w = n
k.t = j
k.v = j
k.w = h
n.o = k
n.q = h
j.y = m
j.v = l
h.u = n
m.y = j
m.v = l
c.q = g
c.s = g
c.u = k
f.t = j
f.v = m
f.w = h
assert f.w.u.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

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

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

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

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

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

l = A("l")
g = B("g")
k = C("k")
n = D("n")
j = E("j")
h = F("h")
m = E("m")
c = A("c")
f = C("f")

l.q = g
l.s = g
l.u = k
g.w = n
k.t = j
k.v = j
k.w = h
n.o = k
n.q = h
j.y = m
j.v = l
h.u = n
m.y = j
m.v = l
c.q = g
c.s = g
c.u = k
f.t = j
f.v = m
f.w = h
assert f.w.u.o.w.txt == "h"