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

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

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

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

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

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

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

l.q = j
h.u = j
h.o = a
h.p = d
h.x = m
h.t = m
h.w = m
d.x = a
d.o = l
d.q = h
a.u = l
j.r = f
m.s = l
m.o = d
m.q = j
f.u = j
f.o = a
f.p = d
f.x = m
f.t = m
f.w = m
assert a.u.q.r.p.q.p.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.txt = txt

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

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

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

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

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

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

l.q = j
h.u = j
h.o = a
h.p = d
h.x = m
h.t = m
h.w = m
d.x = a
d.o = l
d.q = h
a.u = l
j.r = f
m.s = l
m.o = d
m.q = j
f.u = j
f.o = a
f.p = d
f.x = m
f.t = m
f.w = m
assert a.u.q.r.p.q.p.txt == "d"