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

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

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

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

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

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

e = A("e")
k = B("k")
m = C("m")
a = D("a")
l = E("l")
i = F("i")

e.u = a
k.p = e
k.q = a
k.o = l
m.r = a
m.q = l
a.z = e
l.x = e
i.u = e
assert l.x.u.z.u.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

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

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

e = A("e")
k = B("k")
m = C("m")
a = D("a")
l = E("l")
i = F("i")

e.u = a
k.p = e
k.q = a
k.o = l
m.r = a
m.q = l
a.z = e
l.x = e
i.u = e
assert l.x.u.z.u.txt == "a"