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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: F = None
        self.q: G = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

l = A("l")
i = B("i")
e = C("e")
d = D("d")
j = E("j")
c = F("c")
f = G("f")

l.v = f
l.w = i
l.p = j
i.z = l
i.v = e
i.q = c
i.p = c
e.q = d
e.z = f
e.y = i
d.o = i
d.y = i
d.p = f
j.x = c
j.u = c
j.q = f
c.v = d
c.x = j
f.t = d
assert l.w.q.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: G = None
        self.w: B = None
        self.p: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: F = None
        self.u: F = None
        self.q: G = None
        self.txt = txt

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

class G:
    def __init__(self, txt: str):
        self.t: D = None
        self.txt = txt

l = A("l")
i = B("i")
e = C("e")
d = D("d")
j = E("j")
c = F("c")
f = G("f")

l.v = f
l.w = i
l.p = j
i.z = l
i.v = e
i.q = c
i.p = c
e.q = d
e.z = f
e.y = i
d.o = i
d.y = i
d.p = f
j.x = c
j.u = c
j.q = f
c.v = d
c.x = j
f.t = d
assert l.w.q.v.p.txt == "f"