class A:
    def __init__(self, txt: str):
        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.p: D = None
        self.v: B = None
        self.t: B = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
c = B("c")
l = C("l")
f = D("f")
m = A("m")

g.v = c
c.w = l
l.p = f
l.v = c
l.t = c
l.y = m
f.y = l
f.o = l
f.v = c
m.v = c
assert f.v.w.y.v.txt == "
class A:
    def __init__(self, txt: str):
        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.p: D = None
        self.v: B = None
        self.t: B = None
        self.y: A = None
        self.txt = txt

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

g = A("g")
c = B("c")
l = C("l")
f = D("f")
m = A("m")

g.v = c
c.w = l
l.p = f
l.v = c
l.t = c
l.y = m
f.y = l
f.o = l
f.v = c
m.v = c
assert f.v.w.y.v.txt == "c"