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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: E = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

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

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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.o: B = None
        self.r: E = None
        self.s: B = None
        self.u: C = None
        self.txt = txt

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

d.s = m
m.s = h
g.o = n
g.q = f
h.x = n
h.o = l
l.u = g
l.y = d
l.q = h
b.o = n
b.r = l
b.s = m
b.u = g
n.s = h
f.o = m
f.q = g
assert d.s.s.x.s.o.u.txt == "g"