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

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

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

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

g = A("g")
m = B("m")
h = C("h")
k = D("k")
i = B("i")
b = B("b")
j = B("j")
l = D("l")

g.y = h
g.p = h
g.v = b
g.w = k
m.p = h
h.o = j
h.w = b
h.v = g
k.u = l
k.p = b
k.w = j
k.r = h
i.p = h
b.p = h
j.p = h
l.u = k
l.p = i
l.w = b
l.r = h
assert m.p.w.p.v.w.r.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.v: B = None
        self.p: C = None
        self.w: D = None
        self.txt = txt

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

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

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

g = A("g")
m = B("m")
h = C("h")
k = D("k")
i = B("i")
b = B("b")
j = B("j")
l = D("l")

g.y = h
g.p = h
g.v = b
g.w = k
m.p = h
h.o = j
h.w = b
h.v = g
k.u = l
k.p = b
k.w = j
k.r = h
i.p = h
b.p = h
j.p = h
l.u = k
l.p = i
l.w = b
l.r = h
assert m.p.w.p.v.w.r.w.txt == "b"