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

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

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

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

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

f = A("f")
c = B("c")
e = C("e")
a = D("a")
h = E("h")
b = E("b")
m = C("m")
l = E("l")

f.o = l
f.p = m
c.w = f
c.x = f
c.q = e
e.w = m
e.r = m
e.s = h
e.x = c
a.p = c
a.t = l
h.r = b
h.p = c
b.r = l
b.p = c
m.w = e
m.r = e
m.s = h
m.x = c
l.r = h
l.p = c
assert e.x.x.o.r.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.p: C = None
        self.txt = txt

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

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

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

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

f = A("f")
c = B("c")
e = C("e")
a = D("a")
h = E("h")
b = E("b")
m = C("m")
l = E("l")

f.o = l
f.p = m
c.w = f
c.x = f
c.q = e
e.w = m
e.r = m
e.s = h
e.x = c
a.p = c
a.t = l
h.r = b
h.p = c
b.r = l
b.p = c
m.w = e
m.r = e
m.s = h
m.x = c
l.r = h
l.p = c
assert e.x.x.o.r.p.w.txt == "f"