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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
m = C("m")
g = D("g")
b = E("b")
j = C("j")

c.p = j
c.r = g
l.v = b
l.p = b
l.r = c
m.s = b
g.x = b
b.v = j
b.q = l
j.s = b
assert m.s.v.s.q.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
m = C("m")
g = D("g")
b = E("b")
j = C("j")

c.p = j
c.r = g
l.v = b
l.p = b
l.r = c
m.s = b
g.x = b
b.v = j
b.q = l
j.s = b
assert m.s.v.s.q.r.p.txt == "j"