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

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

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

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

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

b = A("b")
g = B("g")
l = C("l")
d = D("d")
i = E("i")
k = E("k")

b.y = k
b.u = g
b.r = g
b.q = l
g.p = b
l.v = g
d.r = g
d.v = l
i.p = g
i.r = l
k.p = g
k.r = l
assert l.v.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: E = None
        self.u: B = None
        self.r: B = None
        self.q: C = None
        self.txt = txt

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

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

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

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

b = A("b")
g = B("g")
l = C("l")
d = D("d")
i = E("i")
k = E("k")

b.y = k
b.u = g
b.r = g
b.q = l
g.p = b
l.v = g
d.r = g
d.v = l
i.p = g
i.r = l
k.p = g
k.r = l
assert l.v.p.r.txt == "g"