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

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
b = C("b")
j = D("j")
a = E("a")
l = B("l")

g.r = b
f.o = a
f.w = a
b.t = g
j.x = f
j.w = f
j.y = g
j.o = a
a.w = b
a.r = b
a.s = g
a.x = g
a.z = f
l.o = a
l.w = a
assert j.y.r.t.r.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.t: A = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
b = C("b")
j = D("j")
a = E("a")
l = B("l")

g.r = b
f.o = a
f.w = a
b.t = g
j.x = f
j.w = f
j.y = g
j.o = a
a.w = b
a.r = b
a.s = g
a.x = g
a.z = f
l.o = a
l.w = a
assert j.y.r.t.r.t.r.txt == "b"