class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.y: D = None
        self.x: D = None
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

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

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

d = A("d")
k = B("k")
g = C("g")
h = D("h")
b = E("b")
n = F("n")
a = C("a")

d.t = n
d.y = h
d.x = h
d.u = k
d.z = g
k.x = b
g.w = d
g.t = b
h.y = n
b.p = k
n.t = d
n.z = d
a.w = d
a.t = b
assert g.t.p.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: F = None
        self.y: D = None
        self.x: D = None
        self.u: B = None
        self.z: C = None
        self.txt = txt

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

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

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

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

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

d = A("d")
k = B("k")
g = C("g")
h = D("h")
b = E("b")
n = F("n")
a = C("a")

d.t = n
d.y = h
d.x = h
d.u = k
d.z = g
k.x = b
g.w = d
g.t = b
h.y = n
b.p = k
n.t = d
n.z = d
a.w = d
a.t = b
assert g.t.p.x.p.txt == "k"