class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.r: F = None
        self.w: D = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = 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.s: B = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: F = None
        self.t: D = None
        self.p: A = None
        self.v: A = None
        self.s: D = None
        self.y: A = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
d = D("d")
j = E("j")
b = F("b")
a = G("a")

i.y = a
i.r = b
i.w = d
i.q = j
l.q = h
h.p = d
d.s = l
j.v = b
j.t = a
j.p = i
b.t = i
a.x = i
a.p = i
a.v = i
a.y = i
a.r = b
a.t = d
a.s = d
assert h.p.s.q.txt == "
class A:
    def __init__(self, txt: str):
        self.y: G = None
        self.r: F = None
        self.w: D = None
        self.q: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: C = 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.s: B = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.x: A = None
        self.r: F = None
        self.t: D = None
        self.p: A = None
        self.v: A = None
        self.s: D = None
        self.y: A = None
        self.txt = txt

i = A("i")
l = B("l")
h = C("h")
d = D("d")
j = E("j")
b = F("b")
a = G("a")

i.y = a
i.r = b
i.w = d
i.q = j
l.q = h
h.p = d
d.s = l
j.v = b
j.t = a
j.p = i
b.t = i
a.x = i
a.p = i
a.v = i
a.y = i
a.r = b
a.t = d
a.s = d
assert h.p.s.q.txt == "h"