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

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: D = None
        self.w: F = None
        self.p: B = None
        self.txt = txt

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

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

a.o = c
a.p = d
c.o = n
f.v = n
d.u = a
d.y = a
d.s = f
n.v = d
n.y = d
n.w = l
n.p = c
l.z = n
l.r = d
e.o = n
assert l.r.s.v.w.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: D = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: D = None
        self.w: F = None
        self.p: B = None
        self.txt = txt

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

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

a.o = c
a.p = d
c.o = n
f.v = n
d.u = a
d.y = a
d.s = f
n.v = d
n.y = d
n.w = l
n.p = c
l.z = n
l.r = d
e.o = n
assert l.r.s.v.w.z.y.txt == "d"