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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.y: F = None
        self.z: D = None
        self.x: F = None
        self.p: C = None
        self.txt = txt

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

a = A("a")
n = B("n")
l = C("l")
f = D("f")
g = E("g")
h = F("h")

a.y = h
a.r = f
n.y = g
n.p = g
n.w = l
l.q = f
f.t = l
g.v = n
g.o = n
g.y = h
g.x = h
g.z = f
g.p = l
h.z = a
h.q = f
h.v = g
assert f.t.q.t.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: F = None
        self.r: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: B = None
        self.o: B = None
        self.y: F = None
        self.z: D = None
        self.x: F = None
        self.p: C = None
        self.txt = txt

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

a = A("a")
n = B("n")
l = C("l")
f = D("f")
g = E("g")
h = F("h")

a.y = h
a.r = f
n.y = g
n.p = g
n.w = l
l.q = f
f.t = l
g.v = n
g.o = n
g.y = h
g.x = h
g.z = f
g.p = l
h.z = a
h.q = f
h.v = g
assert f.t.q.t.q.t.txt == "l"