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

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: B = None
        self.w: A = None
        self.z: F = None
        self.txt = txt

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

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

d = A("d")
g = B("g")
l = C("l")
a = D("a")
c = E("c")
k = F("k")
f = F("f")

d.z = c
d.v = g
g.w = l
l.w = a
l.r = a
l.p = f
a.y = d
a.w = d
a.x = g
a.z = f
c.s = d
c.p = g
k.p = c
f.p = c
assert g.w.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.v: B = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: B = None
        self.w: A = None
        self.z: F = None
        self.txt = txt

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

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

d = A("d")
g = B("g")
l = C("l")
a = D("a")
c = E("c")
k = F("k")
f = F("f")

d.z = c
d.v = g
g.w = l
l.w = a
l.r = a
l.p = f
a.y = d
a.w = d
a.x = g
a.z = f
c.s = d
c.p = g
k.p = c
f.p = c
assert g.w.r.z.txt == "f"