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

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
d = C("d")
i = D("i")
c = E("c")
l = C("l")
f = B("f")
n = D("n")
g = A("g")

h.r = n
h.y = n
h.o = g
h.t = g
e.y = f
e.q = c
e.x = h
d.o = c
i.p = f
i.x = n
c.z = e
l.o = c
f.y = e
f.q = c
f.x = g
n.p = e
n.x = i
g.r = i
g.y = n
g.o = h
g.t = h
assert f.q.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.y: D = None
        self.o: A = None
        self.t: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

h = A("h")
e = B("e")
d = C("d")
i = D("i")
c = E("c")
l = C("l")
f = B("f")
n = D("n")
g = A("g")

h.r = n
h.y = n
h.o = g
h.t = g
e.y = f
e.q = c
e.x = h
d.o = c
i.p = f
i.x = n
c.z = e
l.o = c
f.y = e
f.q = c
f.x = g
n.p = e
n.x = i
g.r = i
g.y = n
g.o = h
g.t = h
assert f.q.z.y.txt == "f"