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

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

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

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

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

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

f = A("f")
g = B("g")
j = C("j")
m = D("m")
d = E("d")
i = F("i")
e = F("e")

f.o = j
f.y = i
g.q = i
g.x = d
j.r = e
j.p = g
m.r = f
m.w = f
m.z = j
d.v = f
i.p = j
i.y = g
e.p = j
e.y = g
assert j.r.y.q.p.r.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: F = None
        self.txt = txt

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

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

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

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

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

f = A("f")
g = B("g")
j = C("j")
m = D("m")
d = E("d")
i = F("i")
e = F("e")

f.o = j
f.y = i
g.q = i
g.x = d
j.r = e
j.p = g
m.r = f
m.w = f
m.z = j
d.v = f
i.p = j
i.y = g
e.p = j
e.y = g
assert j.r.y.q.p.r.p.r.txt == "e"