class A:
    def __init__(self, txt: str):
        self.t: G = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: A = None
        self.q: H = None
        self.p: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

k = A("k")
i = B("i")
g = C("g")
a = D("a")
m = E("m")
d = F("d")
n = G("n")
e = H("e")

k.t = n
i.r = g
g.u = k
a.v = n
m.v = i
m.r = k
m.p = k
m.q = e
d.q = g
n.y = i
e.w = a
assert e.w.v.y.r.u.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: G = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.r: A = None
        self.q: H = None
        self.p: A = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

k = A("k")
i = B("i")
g = C("g")
a = D("a")
m = E("m")
d = F("d")
n = G("n")
e = H("e")

k.t = n
i.r = g
g.u = k
a.v = n
m.v = i
m.r = k
m.p = k
m.q = e
d.q = g
n.y = i
e.w = a
assert e.w.v.y.r.u.t.y.txt == "i"