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

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

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

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

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

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

n = A("n")
e = B("e")
k = C("k")
c = D("c")
h = E("h")
l = F("l")
g = C("g")

n.r = g
e.o = n
e.x = k
k.s = c
c.x = l
c.y = n
c.w = n
h.y = c
l.p = h
l.y = h
l.s = h
l.r = k
g.s = c
assert h.y.w.r.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

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

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

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

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

n = A("n")
e = B("e")
k = C("k")
c = D("c")
h = E("h")
l = F("l")
g = C("g")

n.r = g
e.o = n
e.x = k
k.s = c
c.x = l
c.y = n
c.w = n
h.y = c
l.p = h
l.y = h
l.s = h
l.r = k
g.s = c
assert h.y.w.r.s.y.txt == "n"