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

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.t: F = None
        self.w: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: C = None
        self.p: C = None
        self.txt = txt

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

d = A("d")
i = B("i")
j = C("j")
m = D("m")
l = E("l")
k = F("k")

d.u = j
i.y = l
i.r = m
j.x = i
j.q = m
m.v = j
m.s = d
m.t = k
m.w = l
l.v = k
l.r = j
l.p = j
k.t = i
k.u = i
assert l.p.q.s.u.q.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.v: C = None
        self.s: A = None
        self.t: F = None
        self.w: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.v: F = None
        self.r: C = None
        self.p: C = None
        self.txt = txt

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

d = A("d")
i = B("i")
j = C("j")
m = D("m")
l = E("l")
k = F("k")

d.u = j
i.y = l
i.r = m
j.x = i
j.q = m
m.v = j
m.s = d
m.t = k
m.w = l
l.v = k
l.r = j
l.p = j
k.t = i
k.u = i
assert l.p.q.s.u.q.txt == "m"