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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: F = None
        self.z: B = None
        self.w: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: F = None
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

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

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

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

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

class D:
    def __init__(self, txt: str):
        self.x: A = None
        self.v: F = None
        self.z: B = None
        self.w: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: F = None
        self.t: C = None
        self.q: B = None
        self.txt = txt

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

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

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