class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

d.x = a
d.o = i
g.p = c
l.o = c
l.y = b
l.x = d
c.o = l
b.r = c
b.v = i
i.r = c
i.v = b
a.p = c
assert g.p.o.x.o.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: E = None
        self.txt = txt

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

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

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

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

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

d.x = a
d.o = i
g.p = c
l.o = c
l.y = b
l.x = d
c.o = l
b.r = c
b.v = i
i.r = c
i.v = b
a.p = c
assert g.p.o.x.o.v.v.txt == "i"