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

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

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

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

j = A("j")
b = B("b")
d = C("d")
i = D("i")
c = C("c")
e = A("e")
n = D("n")
k = B("k")
g = C("g")

j.r = b
j.v = k
b.p = k
b.v = g
d.x = b
d.u = e
d.y = g
d.r = g
i.w = g
i.x = g
c.x = k
c.u = e
c.y = d
c.r = g
e.r = k
e.v = b
n.w = g
n.x = g
k.p = b
k.v = d
g.x = b
g.u = e
g.y = d
g.r = c
assert e.r.p.v.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.v: B = None
        self.txt = txt

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

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

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

j = A("j")
b = B("b")
d = C("d")
i = D("i")
c = C("c")
e = A("e")
n = D("n")
k = B("k")
g = C("g")

j.r = b
j.v = k
b.p = k
b.v = g
d.x = b
d.u = e
d.y = g
d.r = g
i.w = g
i.x = g
c.x = k
c.u = e
c.y = d
c.r = g
e.r = k
e.v = b
n.w = g
n.x = g
k.p = b
k.v = d
g.x = b
g.u = e
g.y = d
g.r = c
assert e.r.p.v.txt == "g"