class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: C = None
        self.s: C = None
        self.y: D = None
        self.z: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

d = A("d")
g = B("g")
e = C("e")
f = D("f")
l = E("l")
n = F("n")
i = G("i")

d.p = n
d.r = e
d.s = e
d.y = f
d.z = f
g.y = i
g.x = l
g.p = l
e.q = g
f.v = d
f.q = d
f.z = i
l.u = d
n.p = l
n.r = g
i.s = n
assert d.r.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.r: C = None
        self.s: C = None
        self.y: D = None
        self.z: D = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.p: E = None
        self.r: B = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

d = A("d")
g = B("g")
e = C("e")
f = D("f")
l = E("l")
n = F("n")
i = G("i")

d.p = n
d.r = e
d.s = e
d.y = f
d.z = f
g.y = i
g.x = l
g.p = l
e.q = g
f.v = d
f.q = d
f.z = i
l.u = d
n.p = l
n.r = g
i.s = n
assert d.r.q.p.txt == "l"