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

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

j = A("j")
i = B("i")
l = C("l")
n = D("n")
b = C("b")
d = D("d")
g = C("g")

j.v = g
i.w = j
i.r = g
l.y = b
l.u = b
l.r = b
l.p = i
n.z = j
b.y = g
b.r = g
b.u = l
b.p = i
d.z = j
g.y = l
g.u = l
g.p = i
g.r = b
assert g.p.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

j = A("j")
i = B("i")
l = C("l")
n = D("n")
b = C("b")
d = D("d")
g = C("g")

j.v = g
i.w = j
i.r = g
l.y = b
l.u = b
l.r = b
l.p = i
n.z = j
b.y = g
b.r = g
b.u = l
b.p = i
d.z = j
g.y = l
g.u = l
g.p = i
g.r = b
assert g.p.r.p.txt == "i"