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

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

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

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

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

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

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

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

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

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

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

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

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

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

n.s = g
f.o = h
f.r = n
g.p = n
g.v = m
b.s = d
h.q = l
h.s = m
m.z = h
m.y = h
m.x = f
m.q = n
m.o = d
d.z = h
d.y = h
d.x = f
d.q = n
d.o = m
j.s = l
l.p = j
l.v = m
assert g.p.s.p.s.txt == "g"