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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
n = C("n")
k = D("k")
l = D("l")
d = C("d")

e.y = k
g.p = d
g.q = d
g.v = d
g.y = l
n.p = d
n.x = k
n.r = e
k.q = g
l.q = g
d.p = n
d.x = l
d.r = e
assert l.q.p.x.q.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.x: D = None
        self.r: A = None
        self.txt = txt

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

e = A("e")
g = B("g")
n = C("n")
k = D("k")
l = D("l")
d = C("d")

e.y = k
g.p = d
g.q = d
g.v = d
g.y = l
n.p = d
n.x = k
n.r = e
k.q = g
l.q = g
d.p = n
d.x = l
d.r = e
assert l.q.p.x.q.v.p.txt == "n"