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

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

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

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

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

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

g = A("g")
b = B("b")
e = C("e")
k = D("k")
l = E("l")
n = F("n")

g.z = l
b.q = k
e.x = g
e.r = g
k.p = g
k.y = g
l.t = b
n.t = k
n.p = e
assert e.x.z.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

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

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

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

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

g = A("g")
b = B("b")
e = C("e")
k = D("k")
l = E("l")
n = F("n")

g.z = l
b.q = k
e.x = g
e.r = g
k.p = g
k.y = g
l.t = b
n.t = k
n.p = e
assert e.x.z.t.q.txt == "k"