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

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.z: A = None
        self.v: A = None
        self.o: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.y: F = None
        self.p: B = None
        self.o: A = None
        self.t: D = None
        self.u: E = None
        self.txt = txt

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

c.x = d
d.p = g
a.r = n
a.w = n
a.y = e
a.p = c
a.z = g
l.y = a
n.w = a
n.z = c
n.v = c
n.o = d
e.q = c
e.r = c
e.v = a
e.y = n
e.t = l
g.r = n
g.z = n
g.u = n
g.y = e
g.p = d
g.o = c
g.t = l
assert c.x.p.z.o.p.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.z: A = None
        self.v: A = None
        self.o: B = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.r: E = None
        self.z: E = None
        self.y: F = None
        self.p: B = None
        self.o: A = None
        self.t: D = None
        self.u: E = None
        self.txt = txt

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

c.x = d
d.p = g
a.r = n
a.w = n
a.y = e
a.p = c
a.z = g
l.y = a
n.w = a
n.z = c
n.v = c
n.o = d
e.q = c
e.r = c
e.v = a
e.y = n
e.t = l
g.r = n
g.z = n
g.u = n
g.y = e
g.p = d
g.o = c
g.t = l
assert c.x.p.z.o.p.o.x.txt == "d"