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

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

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

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

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

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

a = A("a")
n = B("n")
f = C("f")
h = D("h")
b = E("b")
j = F("j")

a.t = h
a.p = j
n.u = j
n.z = f
n.x = a
f.x = n
f.s = n
f.w = a
h.y = a
b.z = a
j.u = b
j.y = h
j.r = f
assert h.y.p.y.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.p: F = None
        self.txt = txt

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

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

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

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

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

a = A("a")
n = B("n")
f = C("f")
h = D("h")
b = E("b")
j = F("j")

a.t = h
a.p = j
n.u = j
n.z = f
n.x = a
f.x = n
f.s = n
f.w = a
h.y = a
b.z = a
j.u = b
j.y = h
j.r = f
assert h.y.p.y.y.t.y.txt == "a"