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

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

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

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

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

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

c = A("c")
d = B("d")
l = C("l")
a = D("a")
f = E("f")
g = F("g")
m = A("m")

c.o = f
d.s = c
d.r = m
l.o = f
a.w = c
a.u = m
f.w = l
f.x = a
g.y = m
m.o = f
assert a.u.o.x.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.txt = txt

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

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

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

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

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

c = A("c")
d = B("d")
l = C("l")
a = D("a")
f = E("f")
g = F("g")
m = A("m")

c.o = f
d.s = c
d.r = m
l.o = f
a.w = c
a.u = m
f.w = l
f.x = a
g.y = m
m.o = f
assert a.u.o.x.txt == "a"