class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: F = None
        self.r: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.y: D = None
        self.x: C = None
        self.txt = txt

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

b = A("b")
e = B("e")
m = C("m")
i = D("i")
g = E("g")
l = F("l")
h = G("h")
d = E("d")

b.x = e
b.y = l
b.r = l
e.t = g
m.p = b
i.t = h
i.v = h
i.s = d
g.s = e
g.y = b
l.r = e
l.v = e
l.y = i
l.x = m
h.q = b
h.u = b
h.t = i
d.s = e
d.y = b
assert b.y.y.t.q.y.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.y: F = None
        self.r: F = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.y: D = None
        self.x: C = None
        self.txt = txt

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

b = A("b")
e = B("e")
m = C("m")
i = D("i")
g = E("g")
l = F("l")
h = G("h")
d = E("d")

b.x = e
b.y = l
b.r = l
e.t = g
m.p = b
i.t = h
i.v = h
i.s = d
g.s = e
g.y = b
l.r = e
l.v = e
l.y = i
l.x = m
h.q = b
h.u = b
h.t = i
d.s = e
d.y = b
assert b.y.y.t.q.y.r.t.txt == "g"