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

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
c = C("c")
f = D("f")
j = E("j")
n = F("n")
i = F("i")

m.q = c
m.s = j
g.w = c
g.q = c
g.p = j
g.o = f
g.y = m
c.y = j
c.s = f
f.s = c
j.u = g
j.y = n
n.x = f
i.x = f
assert n.x.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.u: B = None
        self.y: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
c = C("c")
f = D("f")
j = E("j")
n = F("n")
i = F("i")

m.q = c
m.s = j
g.w = c
g.q = c
g.p = j
g.o = f
g.y = m
c.y = j
c.s = f
f.s = c
j.u = g
j.y = n
n.x = f
i.x = f
assert n.x.s.s.txt == "f"