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

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

class C:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
k = C("k")
l = D("l")
e = E("e")
i = F("i")
a = B("a")

g.q = i
g.x = e
g.o = a
g.t = c
g.z = k
g.p = k
c.y = e
k.r = i
l.z = g
e.t = l
e.q = g
i.t = g
i.p = g
i.u = k
a.y = e
assert a.y.q.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: F = None
        self.x: E = None
        self.o: B = None
        self.t: B = None
        self.z: C = None
        self.p: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
k = C("k")
l = D("l")
e = E("e")
i = F("i")
a = B("a")

g.q = i
g.x = e
g.o = a
g.t = c
g.z = k
g.p = k
c.y = e
k.r = i
l.z = g
e.t = l
e.q = g
i.t = g
i.p = g
i.u = k
a.y = e
assert a.y.q.p.r.txt == "i"