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

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

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

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

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

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

d = A("d")
l = B("l")
e = C("e")
h = D("h")
a = E("a")
c = F("c")

d.o = e
d.w = h
d.p = h
l.w = h
l.o = a
l.x = c
e.r = l
h.r = e
h.u = a
a.u = l
a.q = l
a.s = e
a.o = h
c.o = l
assert h.u.o.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.w: D = None
        self.p: D = None
        self.txt = txt

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

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

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

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

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

d = A("d")
l = B("l")
e = C("e")
h = D("h")
a = E("a")
c = F("c")

d.o = e
d.w = h
d.p = h
l.w = h
l.o = a
l.x = c
e.r = l
h.r = e
h.u = a
a.u = l
a.q = l
a.s = e
a.o = h
c.o = l
assert h.u.o.u.q.txt == "l"