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

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.p: F = None
        self.y: G = None
        self.q: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: G = None
        self.x: A = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: F = None
        self.q: E = None
        self.t: E = None
        self.u: B = None
        self.txt = txt

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

h.p = g
b.t = c
b.p = c
b.y = n
b.q = h
g.x = n
g.t = i
g.r = h
i.w = n
i.x = h
l.x = b
l.r = b
l.s = c
l.p = c
l.w = c
l.y = i
l.q = h
c.t = h
c.p = h
c.r = i
n.o = g
n.x = c
n.q = l
n.t = l
n.u = b
assert b.t.p.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: F = None
        self.p: F = None
        self.y: G = None
        self.q: A = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: G = None
        self.x: A = None
        self.txt = txt

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

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

class G:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: F = None
        self.q: E = None
        self.t: E = None
        self.u: B = None
        self.txt = txt

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

h.p = g
b.t = c
b.p = c
b.y = n
b.q = h
g.x = n
g.t = i
g.r = h
i.w = n
i.x = h
l.x = b
l.r = b
l.s = c
l.p = c
l.w = c
l.y = i
l.q = h
c.t = h
c.p = h
c.r = i
n.o = g
n.x = c
n.q = l
n.t = l
n.u = b
assert b.t.p.p.t.txt == "i"