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

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

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

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

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

l.p = h
l.w = n
h.q = g
n.o = j
n.y = b
i.v = c
i.z = j
b.v = c
b.z = n
c.p = h
c.w = n
j.o = n
j.y = b
g.p = h
g.w = n
assert n.o.o.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.w: C = None
        self.txt = txt

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

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

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

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

l.p = h
l.w = n
h.q = g
n.o = j
n.y = b
i.v = c
i.z = j
b.v = c
b.z = n
c.p = h
c.w = n
j.o = n
j.y = b
g.p = h
g.w = n
assert n.o.o.y.v.txt == "c"