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

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

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

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

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

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

c = A("c")
g = B("g")
b = C("b")
n = D("n")
h = E("h")
m = F("m")
k = F("k")

c.w = b
c.p = b
c.y = k
c.s = k
g.r = c
g.s = n
g.q = k
g.x = m
b.y = g
n.p = g
h.u = b
h.x = c
m.q = b
m.x = g
k.q = b
k.x = g
assert n.p.s.p.x.x.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.p: C = None
        self.y: F = None
        self.s: F = None
        self.txt = txt

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

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

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

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

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

c = A("c")
g = B("g")
b = C("b")
n = D("n")
h = E("h")
m = F("m")
k = F("k")

c.w = b
c.p = b
c.y = k
c.s = k
g.r = c
g.s = n
g.q = k
g.x = m
b.y = g
n.p = g
h.u = b
h.x = c
m.q = b
m.x = g
k.q = b
k.x = g
assert n.p.s.p.x.x.s.p.txt == "g"