class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

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

a = A("a")
b = B("b")
d = C("d")
l = D("l")
i = E("i")
c = F("c")
k = F("k")

a.p = b
a.v = b
b.z = d
b.u = l
d.q = k
l.x = a
l.w = a
l.t = a
i.v = k
c.z = l
k.z = l
assert k.z.w.p.z.q.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.v: B = None
        self.txt = txt

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

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

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

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

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

a = A("a")
b = B("b")
d = C("d")
l = D("l")
i = E("i")
c = F("c")
k = F("k")

a.p = b
a.v = b
b.z = d
b.u = l
d.q = k
l.x = a
l.w = a
l.t = a
i.v = k
c.z = l
k.z = l
assert k.z.w.p.z.q.z.t.txt == "a"