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

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

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

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

g = A("g")
i = B("i")
b = C("b")
l = D("l")
m = D("m")
n = A("n")
f = B("f")
d = A("d")
e = D("e")

g.p = i
i.w = g
i.z = f
i.y = f
b.q = l
l.v = f
l.q = b
m.v = i
m.q = b
n.p = f
f.w = d
f.z = i
f.y = i
d.p = f
e.v = f
e.q = b
assert i.w.p.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
b = C("b")
l = D("l")
m = D("m")
n = A("n")
f = B("f")
d = A("d")
e = D("e")

g.p = i
i.w = g
i.z = f
i.y = f
b.q = l
l.v = f
l.q = b
m.v = i
m.q = b
n.p = f
f.w = d
f.z = i
f.y = i
d.p = f
e.v = f
e.q = b
assert i.w.p.w.p.txt == "i"